Reputation: 39
I want to use JodaTime LocalDate with hibernate. I wrote this:
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DATE_DEBUT", nullable = false)
@Type(type = "org.joda.time.contrib.hibernate.PersistentLocalDate")
private LocalDate dateDebut;
but it didn't work. I get this error :
Caused by: Exception [EclipseLink-7165] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The type [class org.joda.time.LocalDate] for the attribute [dateDebut] on the entity class [class ch.test.application.beans.mandat.Mandat] is not a valid type for a temporal mapping. The attribute must be defined as java.util.Date or java.util.Calendar.
Do you know why ?
Thanks
Upvotes: 2
Views: 1859
Reputation: 1289
You can use Jadira
All you have to is add this as dependency and then anotae like this:
@Column
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private DateTime endTime;
For more info check their website.
There is another library that integrates Joda Time with Hibernate from Joda themselves. Here is the link. But personally I could not make it work for me.
Upvotes: 1