maaz
maaz

Reputation: 3666

Grails- How to query the list

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

Answers (1)

D&#243;nal
D&#243;nal

Reputation: 187499

List departmentIds = []
// Code to populate departmentIds goes here

def rulesWithTestingDepartment = Rules.withCriteria {
  departments {
    'in'('id', departmentIds)
  }
}

Upvotes: 2

Related Questions