joda.time.DateTime in pojo with hibernate support
hibernate - 3.6.0.Final joda - 1.4 how to support direct joda.DateTime in pojo for hibernate
so can be 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">
<colum开发者_StackOverflown length="10" name="date" />
</key-property>
ERROR:
org.hibernate.MappingException: Could not determine type for: org.joda.time.contrib.hibernate.PersistentDateTime
AND without "type=" ERROR
java.lang.ClassCastException: org.joda.time.DateTime cannot be cast to java.util.Date
Perhaps you don't have Joda-Time Hibernate in the classpath. It's needed for type="org.joda.time.contrib.hibernate.PersistentDateTime"
.
UPDATE:
It appears that Joda-time Hibernate support currently doesn't work with Hibernate 3.6, see PersistentDateTime doesn't work in hibernate 3.6 - ID: 3090209 and Recompile Joda-Time Hibernate to make it work with Hibernate 3.6.
You can use User Type project instead (type attribute becomes type="org.jadira.usertype.dateandtime.joda.PersistentDateTime"
).
精彩评论