I am trying to upgrade my grails application from version 1.3 to 2.5. I have a domain class with one of its fields as Enum. In controller, when I do domainObj.validate(), it always returns false. Validation error is -
grails.validation.ValidationErrors: 1 errors Field error in object 'Parameter' on field 'typeEnum': rejected value [0]; codes [com.TypeEnum.typeMismatch.error,com.TypeEnum.typeMismatch,com.TypeEnum.typeMismatch.error,com.TypeEnum.typeMismatch,typeMismatch.com.TypeEnum,typeMismatch.pspValueTypeEnum,typeMismatch.com.TypeEnum,typeMismatch]; arguments [typeEnum]; default message [No enum constant com.TypeEnum.0]
EDIT: On further analysis, I found that the issue is not with enums, but when parameterObj.properties = params is executed, parameterObj.validate() returns false.
In my code with Grails 2.5,
parameterObj.validate() //returns true
parameterObj.properties = params
// code to convert String from params to Enum object and assign it to parameterObj
parameterObj.enumField = MyEnumClass.getEnumByName(params.enumNameValue)
parameterObj.validate() //This always return false
Note: In both above cases of validate(), field values of parameterObj are exactly same
Are there any changes in using properties on domain class in Grails 2.5 ?