Java pojo中支持hibernate的joda.time.DateTime
hibernate-3.6.0.Final 乔达-1.4 如何在用于hibernate的pojo中支持direct joda.DateTime 因此可以是Java pojo中支持hibernate的joda.time.DateTime,java,hibernate,jodatime,Java,Hibernate,Jodatime,hibernate-3.6.0.Final 乔达-1.4 如何在用于hibernate的pojo中支持direct joda.DateTime 因此可以是session.saveOrUpdate(rateCodeId) 波乔 hbm.xml <key-property name="date" type="org.joda.time.contrib.hibernate.PersistentDateTime"> <column length="10" name="
session.saveOrUpdate(rateCodeId)代码>
波乔
hbm.xml
<key-property name="date" type="org.joda.time.contrib.hibernate.PersistentDateTime">
<column length="10" name="date" />
</key-property>
错误:
org.hibernate.MappingException:无法
不确定以下各项的类型:
org.joda.time.contrib.hibernate.PersistentDateTime
没有“类型=”
错误
java.lang.ClassCastException:
无法强制转换org.joda.time.DateTime
到java.util.Date
也许在类路径中没有。type=“org.joda.time.contrib.hibernate.PersistentDateTime”
需要它
更新:
Joda time Hibernate支持目前似乎不适用于Hibernate 3.6,请参阅和
您可以改为使用(type属性变为type=“org.jadira.usertype.dateandtime.joda.PersistentDateTime”
)。。两个jar joda-time-hibernate-1.2.jar和joda-time-1.6.2.jar也需要添加这个jar,因为“org.joda.time.contrib..”位于hibernate-1.2.jarsession.createQuery(“from RateCode rr where rr.id.date>=:from).setDate/setTimeStamp(“from”,from)其中从映射文件JODA.Timestamp到.setDate需要util.Datejava.lang.NoSuchFieldError:Timestamp位于org.JODA.time.contrib.hibernate.PersistentDateTime.nullSafeSet(PersistentDateTime.java:83)
那么如何使用setDate进行查询呢。感谢更新到joda time hibernate 1.3解决了这个问题。+1更新到hibernate 1.3,这是在发布这个答案后发布的。joda-time-hibernate 1.3拯救了我的一天!
<key-property name="date" type="org.joda.time.contrib.hibernate.PersistentDateTime">
<column length="10" name="date" />
</key-property>