1

我正在尝试使用java.time.LocalDateTime,但显然Hibernate 4.3.5(我正在使用 JPA)不支持LocalDateTime作为TemporalType功能请求)。

是否有任何解决方法可以坚持java.time.LocalDateTimeTemporalTypein Hibernate

什么可能是我最好的替代方案(java.util.Datejodatime),这样我可以LocalDateTime在支持后轻松迁移到它?

4

2 回答 2

0

您可能会发现用户类型项目对于在 Hibernate 中持久化 JSR-310 类很有用。如果它不能开箱即用,源代码应该为您提供有关实现相关 Hibernate 插件点的线索。

于 2014-05-19T08:04:00.787 回答
0

If object creation isn't a problem for you (i.e. GC), joda datetime package is almostly a 1-1 match with java.time package, except that joda package doesn't provide a way to translate the joda date/datetime into milliseconds since epoch while java.time supports it by Instant class.

Sorry not expert in Hibernate so cannot answer your converting question - but suppose you could transfer into some helper class to facilitate persisting?

于 2014-05-19T02:21:09.457 回答