他们婚姻幸福吗?
我使用的是最新版本的 hibernate (4) 和 1.3 版本joda 时间休眠支持 http://www.joda.org/joda-time-hibernate/,我也认为这是当前的最新版本。
使用注释时,一切似乎都工作正常(按预期创建日期列):
@Column
@Type(type="org.joda.time.contrib.hibernate.PersistentLocalDate")
private LocalDate myDate;
一起使用这些版本是否存在任何已知问题?
Update事实证明,列已创建,但无法填充任何数据:
Handler处理失败;嵌套异常是 java.lang.AbstractMethodError: org.joda.time.contrib.hibernate.PersistentLocalDateTime.nullSafeSet
它们不兼容,我应该使用usertype http://usertype.sourceforge.net/.请参阅下面的答案。
文档明显缺乏,这意味着写下集成所需的步骤可能会对我有所帮助。确保您的库是最新的。
你需要:[假设你已经有 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;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)