当前位置: 代码迷 >> 综合 >> hibernate 使用joda-time
  详细解决方案

hibernate 使用joda-time

热度:10   发布时间:2023-10-26 08:59:04.0

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>

  相关解决方案