Grails 3 and Java 8 time support

ε祈祈猫儿з 提交于 2019-12-06 13:49:28

Edit: Grails 3.1.1 has hibernate 5 so this is not an issue anymore...

Grails

I finally found a solution. First of all hibernate 5 implements persistent for java 8 time (https://hibernate.atlassian.net/browse/HHH-8844). However, grails 3 uses hibernate 4 and I haven't found any plans to upgrade hibernate in grails.

There is an implementation for java 8 time hibernate user types (jadira extended package) which can be used similarly as in joda time plugin (see http://gpc.github.io/joda-time/guide/persistence.html). For me only version 3.1.0.GA and lower worked.

build.gradle

dependencies {
    compile "org.jadira.usertype:usertype.extended:3.1.0.GA"
}

application.groovy

grails.gorm.default.mapping = {
    "user-type" type: org.jadira.usertype.dateandtime.threeten.PersistentInstantAsMillisLong, class: java.time.Instant
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!