hibernate - 3.6.0.Final 乔达 - 1.4 如何在 pojo 中支持直接 joda.DateTime for hibernate
也可以是 session.saveOrUpdate(rateCodeId);
波乔
public class RateCodeId implements java.io.Serializable {
private int roomId;
private org.joda.Time.DateTime date;
}
hbm.xml
<key-property name="date" type="org.joda.time.contrib.hibernate.PersistentDateTime">
<column length="10" name="date" />
</key-property>
错误:
org.hibernate.MappingException: Could not determine type for: org.joda.time.contrib.hibernate.PersistentDateTime
AND 没有 "type=" 错误
java.lang.ClassCastException: org.joda.time.DateTime cannot be cast to java.util.Date
最佳答案
也许你没有Joda-Time Hibernate在类路径中。 type="org.joda.time.contrib.hibernate.PersistentDateTime"
需要它。
更新:
看来 Joda-time Hibernate 支持目前不适用于 Hibernate 3.6,请参阅 PersistentDateTime doesn't work in hibernate 3.6 - ID: 3090209和 Recompile Joda-Time Hibernate to make it work with Hibernate 3.6 .
您可以使用 User Type project相反(类型属性变为 type="org.jadira.usertype.dateandtime.joda.PersistentDateTime"
)。
关于java - pojo 中的 joda.time.DateTime 支持 hibernate ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5065367/