如何将 jodaTime 与休眠一起使用

How to use jodaTime with hibernate

我想将 JodaTime LocalDate 与休眠一起使用。我写了这个:

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DATE_DEBUT", nullable = false)
@Type(type = "org.joda.time.contrib.hibernate.PersistentLocalDate")
private LocalDate dateDebut;

但是没用。我收到此错误:

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.

你知道为什么吗?

谢谢

您可以使用Jadira

您所要做的就是将其添加为依赖项,然后像这样添加:

@Column
  @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
  private DateTime endTime;

有关更多信息,请查看他们的 website

还有另一个库将 Joda Time 与 Joda 本身的 Hibernate 集成在一起。这里是link。但就我个人而言,我无法让它为我工作。