我有像这样的域类
Class Rules{
List <Department> departments = new ArrayList<Department>()
// blah blah
static hasMany = [departments:Department]
}
Class Department {
String name
}
def listOfRules= // find the rules based on department selected
我正在尝试获取包含所选部门的所有规则..所以我该如何查询..
这是grails application ..它使用了hibernate。
答案 0 :(得分:2)
List departmentIds = []
// Code to populate departmentIds goes here
def rulesWithTestingDepartment = Rules.withCriteria {
departments {
'in'('id', departmentIds)
}
}