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">
<column 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
So the short answer to your question is: YES (deprecated).
Joda-Time is an API created by joda.org which offers better classes and having efficient methods to handle date and time than classes from java. util package like Calendar, Gregorian Calendar, Date, etc. This API is included in Java 8.0 with the java.
Joda-Time uses immutable objects. So rather than change the time zone ("mutate"), we instantiate a new DateTime object based on the old but with the desired difference (some other time zone).
Joda-Time provides a comprehensive formatting system. There are two layers: High level - pre-packaged constant formatters. Mid level - pattern-based, like SimpleDateFormat. Low level - builder.
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"
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With