冬眠4和乔达时间 [英] hibernate 4 and joda-time
问题描述
我正在使用最新版本的hibernate(4)和1.3版本的 joda-time hibernate支持,我也相信这是当前的最新版本。
使用注释时,一切似乎都正常(按预期创建日期列):
@Column
@Type(type =org.joda.time.contrib.hibernate.PersistentLocalDate)
private LocalDate myDate;
他们在使用这些版本时遇到的任何已知问题?
更新
结果列创建完成,但无法填充任何数据:
处理程序处理失败;嵌套异常是java.lang.AbstractMethodError:org.joda.time.contrib.hibernate.PersistentLocalDateTime.nullSafeSet 它们是不兼容的,我应该使用 usertype 。请参阅下面的答案。 明显缺乏文档,意味着我可能会写下集成所需的步骤。确保你的库是最新的。 你需要:[假设你已经有hibernate4] 最新版本的乔达时间 和usertype lib 然后在实体类中使用以下内容(不一定是LocalDateTime,可以是任何持久化类可用): 以及列定义: are they happily married ? I am using the latest version of hibernate (4) and version 1.3 of joda-time hibernate support, which I also believe to be the current latest release. Everything seems to be working OK (date columns created as expected) when using annotations : Are their any known problems with using these versions together ? Update
Well turns out the columns get created but unable to populate with any data : Handler processing failed; nested exception is java.lang.AbstractMethodError: org.joda.time.contrib.hibernate.PersistentLocalDateTime.nullSafeSet They are incompatible, and I should be using usertype. See answer below. A distinct paucity of documentation, means it might be helpful for me to write down the steps required for integration. Make sure your libraries are up to date. You'll need : [assuming you already have hibernate4] Latest version of joda-time and usertype lib Then use the following in entity classes (doesn't have to be LocalDateTime, could be any of the persisted classes available) : and for column definition:
这篇关于冬眠4和乔达时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
<依赖关系>
< groupId> joda-time< / groupId>
< artifactId> joda-time< / artifactId>
< version> 2.0< / version>
< /依赖关系>
<依赖性>
< groupId> org.jadira.usertype< / groupId>
< artifactId> usertype.core< / artifactId>
< version> 3.0.0.CR1< / version>
< /依赖关系>
import org.joda.time.LocalDateTime;
<$ p $
@Type(type =org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime)
private LocalDateTime更新;
@Column
@Type(type="org.joda.time.contrib.hibernate.PersistentLocalDate")
private LocalDate myDate;
<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>
import org.joda.time.LocalDateTime;
@Column(name="updated", nullable = false)
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
private LocalDateTime updated;