Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented configuration change? #28

Open
pvangent opened this issue Aug 8, 2018 · 3 comments
Open

Undocumented configuration change? #28

pvangent opened this issue Aug 8, 2018 · 3 comments

Comments

@pvangent
Copy link

pvangent commented Aug 8, 2018

I am busy with a (long overdue) upgrade of a Grails2 app to Grails3. Part of the upgrade is maintaining the Joda Time functionality. This has likely succeeded, but with a configuration that is not documented. I am not sure if the plugin's workings have changed, or the documentation is incorrect, but I think it's worth noting.

Some facts about the app:

  • Grails Version: 3.3.6
  • Groovy Version: 2.4.15
  • JVM Version: 1.8.0_161
  • Hibernate: 5.1.5

Joda (related) dependencies in build.gradle:

compile 'org.grails.plugins:joda-time:2.1.0'
compile "org.jadira.usertype:usertype.jodatime:1.9"

In the Grails2 app the Joda <> Hibernate mapping was in a grails.gorm.default.mapping entry in Config.groovy. I moved this to application.groovy, which is the correct place according to this plugin's documentation (and install-mapping script). However, in the Grails3 app grails.gorm.default.mapping does not work. What does work, is using the grails.gorm.default.constraints entry. Like so:

grails.gorm.default.constraints = {
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentDateTime, class: org.joda.time.DateTime
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentDateTimeZoneAsString, class: org.joda.time.DateTimeZone
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentDurationAsString, class: org.joda.time.Duration
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentInstantAsMillisLong, class: org.joda.time.Instant
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentInterval, class: org.joda.time.Interval
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentLocalDate, class: org.joda.time.LocalDate
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime, class: org.joda.time.LocalDateTime
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentLocalTime, class: org.joda.time.LocalTime
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentPeriodAsString, class: org.joda.time.Period
    "user-type" type: org.jadira.usertype.dateandtime.joda.PersistentYears, class: org.joda.time.Years
}

(To be clear: it works fine in the app, but it seems undocumented - at least for this version of the plugin?)

@graemerocher
Copy link
Member

Seems worthy of a pull request to the docs

@pvangent
Copy link
Author

pvangent commented Aug 9, 2018

Right. But doesn't it also require an update of the joda-time/grails-app/commands/grails/plugins/jodatime/InstallJodaTimeGormMappingsCommand.groovy script?

@pvangent
Copy link
Author

The new config grails.gorm.default.constraints worked for a while, until I cleaned the application. After that it would not startup again, with a fatal Hibernate error configuring the datasource. I found some references on the web regarding dependencies between Jadira en Hibernate5.x, and it looks like you should use org.jadira.usertype:usertype.core:5.0.0.GA instead of org.jadira.usertype:usertype.jodatime:1.9. For me it works anyway...

If this is true, that would be another change to the docs I guess?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants