我正在尝试使用java.time.LocalDateTime
,但显然Hibernate 4.3.5
(我正在使用 JPA)不支持LocalDateTime
作为TemporalType
(功能请求)。
是否有任何解决方法可以坚持java.time.LocalDateTime
为TemporalType
in Hibernate
?
什么可能是我最好的替代方案(java.util.Date
或jodatime
),这样我可以LocalDateTime
在支持后轻松迁移到它?
您可能会发现用户类型项目对于在 Hibernate 中持久化 JSR-310 类很有用。如果它不能开箱即用,源代码应该为您提供有关实现相关 Hibernate 插件点的线索。
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?