休眠 - 3.6.0.Final
乔达 - 1.4
如何在pojo中为hibernate支持直接joda.DateTime
所以可以 session.saveOrUpdate(rateCodeId);
POJO
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:可以
不确定类型:
org.joda.time.contrib.hibernate.PersistentDateTime
并且没有“type =”
错误
java.lang.ClassCastException:
org.joda.time.DateTime无法强制转换
到java.util.Date
也许你没有 Joda-Time Hibernate 在类路径中。它需要 type="org.joda.time.contrib.hibernate.PersistentDateTime"
。
更新:
似乎Joda-time Hibernate支持当前不适用于Hibernate 3.6,请参阅 PersistentDateTime在hibernate 3.6中不起作用 - ID:3090209 和 重新编译Joda-Time Hibernate以使其与Hibernate 3.6一起使用。
您可以使用 用户类型项目 相反(类型属性变为 type="org.jadira.usertype.dateandtime.joda.PersistentDateTime"
)。
也许你没有 Joda-Time Hibernate 在类路径中。它需要 type="org.joda.time.contrib.hibernate.PersistentDateTime"
。
更新:
似乎Joda-time Hibernate支持当前不适用于Hibernate 3.6,请参阅 PersistentDateTime在hibernate 3.6中不起作用 - ID:3090209 和 重新编译Joda-Time Hibernate以使其与Hibernate 3.6一起使用。
您可以使用 用户类型项目 相反(类型属性变为 type="org.jadira.usertype.dateandtime.joda.PersistentDateTime"
)。