Java hibernate初始化期间Joda类型def加载失败
使用了Joda time和hibernate支持。配置如下: org.joda.time.package info.java中有typedef:Java hibernate初始化期间Joda类型def加载失败,java,hibernate,spring,jodatime,Java,Hibernate,Spring,Jodatime,使用了Joda time和hibernate支持。配置如下: org.joda.time.package info.java中有typedef: @org.hibernate.annotations.TypeDefs({ @org.hibernate.annotations.TypeDef( name="localDate", typeClass = org.joda.time.contrib.hi
@org.hibernate.annotations.TypeDefs({
@org.hibernate.annotations.TypeDef(
name="localDate",
typeClass =
org.joda.time.contrib.hibernate.PersistentLocalDate.class
)
})
package org.joda.time;
有一个包含会话工厂配置的spring上下文:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="packagesToScan">
<list>
<value>org.joda.time</value>
</list>
</property>
<property name="annotatedClasses">
<list>
<value>...</value>
...
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="dataSource" ref="dataSource"/>
</bean>
问题在下一个例外中:
Caused by: org.hibernate.MappingException: Could not determine type for: localDate, at table: TABLE_NAME, for columns: [org.hibernate.mapping.Column(DATE_COLUMN)]
我使用标准日期映射到数据库,然后在我的getter/setter中使用joda时间并执行转换,以避免出现像您这样的问题 Thanx是答案,但遵循您的建议需要付出太多的努力,使用不同的解决方法更容易,例如向会话工厂添加类型定义属性。我认为这是一个薄弱的解决方法,并不能真正解决手头的问题。@rtcarlson感谢您的评论/投票,也许您可以建议一个不那么薄弱的答案?
Caused by: org.hibernate.MappingException: Could not determine type for: localDate, at table: TABLE_NAME, for columns: [org.hibernate.mapping.Column(DATE_COLUMN)]