我有这两个类:
class Father{
static hasMany= [children:Child]
}
class Child{
String name
}
在我的 Controller 中,我需要查找是否有
father
带有特定的 child
但这不起作用,要求一组 child :Father.countByChildren(Child.get(1))
有什么建议吗?
谢谢
最佳答案
您可以使用标准:
Father.createCriteria().count {
children {
idEq(1L)
}
}
关于 child 找到的Grails 1到n关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45824100/