我正在使用grails应用程序,我想使用java.time来获取我的域类的属性。
我需要将LocalDateTime映射到基于Hibernate构建的GORM上的DATE / DATETIME。
我如何坚持我的映射?
我看到一个解决方案,我可以使用jadira,并为我的属性建立静态映射。
然而有另一种方法吗?
请任何帮助。
解决方案您可以使用用户类型映射。请参阅文档。这应该消除明确映射所有实例的需要。
更进一步,我将采用 grails-joda-time 插件源并尝试制作 jave.time 版本。甚至尝试制作(并提交拉请求)一个支持 joda-time 和 java.time 。
Java 8 gives the java.time API.
I am using a grails application, I want to use java.time for properties of my domain classes.
I need to map for instance the LocalDateTime to the DATE/DATETIME on GORM which is built on top of Hibernate.
How can I persist my mappings?
I see a solution, that I can use jadira, and establish static mappings for my attributs.
However is there another way?
Please any help is appreciated.
解决方案You can use the user type mapping. See the docs. That should remove the need to explicitly map all instances individually.
To go further, I would take the grails-joda-time plugin sources and try to make a jave.time version. And even try to make (and submit a pull request) a version that would support both joda-time and java.time.
更多推荐
Grails将Java 8域对象的LocalDateTime映射到Gorm
发布评论