Reputation: 319
I have this two classes:
class Father{
static hasMany= [children:Child]
}
class Child{
String name
}
and In my controller I need to find if there is any father
with an specific child
but this does not work, asks for a set of children:
Father.countByChildren(Child.get(1))
Any suggest?
Thanks
Upvotes: 1
Views: 54
Reputation: 2555
You can use Criteria:
Father.createCriteria().count {
children {
idEq(1L)
}
}
Upvotes: 2