Persist java.time.Instant (JDK8) with JPA2/Hibernate

点点圈 提交于 2019-11-27 15:03:17

See the ThreeTen home page, where three different JPA libraries are mentioned:

Either use Hibernate 5.2.0+ or for earlier Hibernate 5 add the following dependency:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-java8</artifactId>
        <version>${hibernate.version}</version>
    </dependency>

In Hibernate 5.2 onwards has this issue solved more fully - you no longer need to include the hibernate-java8 dependency from Ipandzic's comment and you can use java.time.* classes such as LocalDateTime or Instant without any additional steps. You also do not need to mark columns using java.util.LocalDateTime etc as Temporal anymore, the way you had to with the older java.util.Date approach.

Since Hibernate 5.2, the hibernate-java8 content has been merged into hibernate-core see the change notes here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!