I have the Grails domain classes Child and Toy. A child can have many toys.
class Child {
static hasMany = [ toys : Toy ]
String name
}
class Toy {
static belongsTo = [ owner : Child ]
String name
}
It was my understanding that there will be a toys property on Child. That is, there will be the Child method:
public Set getToys()
But this doesn't work. I'm unable to reference child.getToys()
from a Java class. I have explicitly define toys in Child:
class Child {
static hasMany = [ toys : Toy ]
String name
Set toys
}
Is this correct? Do I need to explicitly define a Set for a one-to-many relationship?