Thursday, January 17, 2013

Fixing GORM UserType after migration to version 2

Grails allows to define custom UserType to properties like in regular Hibernate, by specifying them next to properties in domain objects, like:


  someproperty type: MyUserType

But after migrating to Grails 2.2, these stopped working and Grails started to treat them as plain objects (enumerations in my particular case). Fortunately, this was easy to fix by defining all custom user types in Config.groovy, like:


grails.gorm.default.mapping = {
  'myproperty-type'(type: my.org.MyUserType, class: my.org.MyEnum)
}

This also defines mapping for all properties of specific type, so no need to do it in every domain class.

1 comment:

  1. The King Casino - Atlantic City, NJ | Jancasino
    Come on in the King 토토 사이트 Casino for fun, casinosites.one no wagering requirements, jancasino.com delicious dining, and enjoyable casino gaming all at the heart of Atlantic https://jancasino.com/review/merit-casino/ City. apr casino

    ReplyDelete