我有这样的 Realm 类
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应用程序..它使用休眠状态。
最佳答案
List departmentIds = []
// Code to populate departmentIds goes here
def rulesWithTestingDepartment = Rules.withCriteria {
departments {
'in'('id', departmentIds)
}
}
关于grails - Grails-如何查询列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8786902/