Grails将Java 8域对象的LocalDateTime映射到Gorm

编程入门 行业动态 更新时间:2024-10-26 18:26:37
本文介绍了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

本文发布于:2023-07-16 04:19:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117765.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对象   Java   Grails   LocalDateTime   Gorm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!