List of Strings in a Grails domain class
grails, grails-orm
Solution
You can achieve this by using `hasMany`. Furthermore you need to define `books` as a `List` since without it you would get a simple `Set` that does not allow any duplicates.
class Catalogue {
static hasMany = [books: String]
List books
}
Problem
I am trying to have a `List` of `String` that works in MySql in a Grails domain class. I have tried the following: ``` class Catalogue { List books String book static hasMany = [books: book] } ``` and ``` class Catalogue { List books } ``` and ``` class Catalogue { String[] books } ``` and ``` class Catalogue { ArrayList<String> books = new ArrayList<String>() } ``` The last three compiles but the entry is not present in MySQL. There is no table, or column to represent this data in MySQL and I have tried populating the array with data. Still nothing. Any ideas?