Reputation: 3666
I have a domain classes like this
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
i am trying to get all the Rules which contains selected departments .. so how can i query that..
this is grails application.. which uses hibernate .
Upvotes: 1
Views: 1563
Reputation: 187499
List departmentIds = []
// Code to populate departmentIds goes here
def rulesWithTestingDepartment = Rules.withCriteria {
departments {
'in'('id', departmentIds)
}
}
Upvotes: 2