Grails将Java 8域对象的LocalDateTime映射到Gorm [英] Grails Mapping LocalDateTime of Java 8 domain objects to Gorm

查看:86
本文介绍了Grails将Java 8域对象的LocalDateTime映射到Gorm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 8提供了java.time API。

我正在使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆