I’m using Hibernate & Joda Time, with support from the UserType library.
I’m able to persist my dates using the following approach:
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@Column
private DateTime startDate;
However, I’m wondering if it’s possible to define this mapping once somewhere, rather than on every instance of the DateTime type.
Having had to swap out from JodaTime Hibernate to UserType when migrating from Hibernate 3.4 -> 4.0, I’m reluctant to have type declarations littered throughout the domain model.
With the 3.0.0.CR1 release of Usertype you can take advantage of autoregistration of the following types:
To enable this feature, you need to set the JPA or Hibernate property ‘jadira.usertype.autoRegisterUserTypes’ to ‘true’.
When upgrading the usertype.joda Maven artifact is now called ‘usertype.core’.
More information is here http://blog.jadira.co.uk/blog/2012/1/19/release-jadira-usertype-300cr1-with-support-for-joda-money-0.html