Hibernate 休眠操作异常

Hibernate 休眠操作异常,hibernate,grails,jodatime,Hibernate,Grails,Jodatime,我正在运行一个grails项目。也许这个问题是针对初学者的,但帮助仍然很重要 我有一个域对象,Order。在order类模型中,我使用Joda Time将dateCreated声明为DateTime类型 我正在使用:'joda-time:joda-time:2.9.2' 但是,在调用order.save()时,我得到以下错误: Exception in thread "main" org.springframework.dao.DataIntegrityViolationException: H

我正在运行一个grails项目。也许这个问题是针对初学者的,但帮助仍然很重要

我有一个域对象,Order。在order类模型中,我使用Joda Time将dateCreated声明为DateTime类型

我正在使用:'joda-time:joda-time:2.9.2'

但是,在调用order.save()时,我得到以下错误:

Exception in thread "main" org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not execute statement; SQL [n/a]; Data truncation: Data too long for column 'date_created' at row 1; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'date_created' at row 1
你能告诉我发生了什么事吗?

看看这个:

在域类中:

import org.joda.time.*
import org.joda.time.contrib.hibernate.*

DateTime dateCreated
DateTime lastUpdated
LocalDate birthday

static mapping = {
    dateCreated type: PersistentDateTime
    lastUpdated type: PersistentDateTime
    birthday type: PersistentLocalDate
}
在Config.groovy中:

grails.gorm.default.mapping = {
    "user-type" type: PersistentDateTime, class: DateTime
    "user-type" type: PersistentLocalDate, class: LocalDate
}

或者。

MySQL数据库中“date\u created”的列类型是什么?第二个解决方案解决了我的问题。非常感谢你。您可以放弃我以前的评论。:)