他们幸福地结婚了吗?
我正在使用最新版本的hibernate(4)和1.3版的joda-time hibernate支持,我也认为这是当前的最新版本。
使用注释时,一切似乎都正常(按预期方式创建了日期列):
@Column
@Type(type="org.joda.time.contrib.hibernate.PersistentLocalDate")
private LocalDate myDate;
一起使用这些版本是否存在任何已知问题?
Update Well证明已创建列,但无法填充任何数据:
处理程序处理失败;嵌套的异常是java.lang.AbstractMethodError:org.joda.time.contrib.hibernate.PersistentLocalDateTime.nullSafeSet
它们不兼容,我应该使用usertype。请参阅下面的答案。
很少有文档说明,这可能有助于我写下集成所需的步骤。确保您的库是最新的。
您需要:[假设您已经有hibernate4]
最新版本的乔达时间
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
和用户类型库
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>3.0.0.CR1</version>
</dependency>
然后在实体类中使用以下内容(不必为LocalDateTime,可以是任何可用的持久化类):
import org.joda.time.LocalDateTime;
对于列定义:
@Column(name="updated", nullable = false)
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
private LocalDateTime updated;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句