Search code examples
hibernategrailsjava-8persistencegrails-orm

Grails Mapping LocalDateTime of Java 8 domain objects to Gorm


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.


Solution

  • 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.