Any ideas on how to persist a collection of enums in Grails?
Groovy enum:
public enum MyEnum {
AAA('Aaa'),
BEE('Bee'),
CEE('Cee')
String description
MyEnum(String description) {
this.description = description
}
static belongsTo = [tester:Tester]
}
I want to use this enum in a Grails domain class. The domain class looks like this:
class Tester {
static hasMany = [myenums: MyEnum]
static constraints = {
}
}
In my create.jsp, I want to be able to select multiple MyEnums and have the following line:
<g:select from="${MyEnum?.values()}" multiple="multiple" value="${testerInstance?.myenums}" name="myenums" ></g:select>`
The problem I'm getting is when I try to create a new Tester, I get a 500 error saying:
Exception Message: java.lang.String cannot be cast to java.lang.Enum
Caused by: java.lang.String cannot be cast to java.lang.Enum
Class: TesterController