hibernate自身不提供对joda-time持久化的功能,则需要引入joda的hibernate支持,用法如下,这里只是举个例子
@Column(name="CREATEDATE")@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")public DateTime getCreateDate() {return createDate;}public void setCreateDate(DateTime createDate) {this.createDate = createDate;}@Column(name="LASTUPDATEDATE")@Type(type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate")public LocalDate getLastUpdateDate() {return lastUpdateDate;}public void setLastUpdateDate(LocalDate lastUpdateDate) {this.lastUpdateDate = lastUpdateDate;}
需要在pom文件中添加以下两个依赖
<dependency><groupId>joda-time</groupId><artifactId>joda-time</artifactId><version>${goda.time.version}</version></dependency><dependency><groupId>org.jadira.usertype</groupId><artifactId>usertype.core</artifactId><version>6.0.1.GA</version></dependency>