Search code examples
grailsarraylistgrails-ormhas-manylinkedhashset

Change grails hasMany from LinkedHashSet to ArrayList


I have the following:

class A{

    static hasMany = [b: B]
}

Grails generates the class with property b being a LinkedHashMap. I want to configure Grails in order to generate an ArrayList instead.

I know this can be done by explicitly writing the list:

class A{

    static hasMany = [b: B]

    List<B> b = new ArrayList<B>()
}

But I was looking for a way to achieve this by some external configuration.


Solution

  • This is not configurable - The only solution is to declare a property of the type list as you did in your sample.