Joda-time:Hibernate Mapping Exception

时间:2016-02-03 14:46:56

标签: java hibernate grails jodatime

我有一个grails-app。域类可以是用户,行为等。 用户有很多行为,行为属于用户。行为模型包括DateCreated的日期。

需要更改项目中使用的时间/日期类型。我必须设置Joda-Time并将所有Date设置为DateTime。

我查看此链接以了解dateCreated:https://grails.org/wiki/JodaTime%20Plugin

在我的build.gradle文件中,我添加了:

compile 'joda-time:joda-time:2.9.2'
compile 'joda-time:joda-time-hibernate:1.4'
compile "org.jadira.usertype:usertype.jodatime:1.9"

在我的Behavior类中,我添加了以下部分:

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

    class Behavior {

        DateTime dateCreated
        static mapping = {
            dateCreated type: PersistentDateTimeTZ, {
                column name: "dateCreated_timestamp"
                column name: "dateCreated_zone"
            }
        }
    }

但是我收到以下错误,我不知道如何解决它。

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: com.p.r.b.user.User, at table: behavior, for columns: [org.hibernate.mapping.Column(user)]

请有人能告诉我发生了什么事吗? 任何解释或评论都非常感谢!

0 个答案:

没有答案