Find class in model with has many relation

52 Views Asked by At

I have following Model:

TestProfessional { 
    static hasMany = [answers: Answer]
}
Answer { 
String answer;
}

How to find TestProfessional with answers having specified id?

1

There are 1 best solutions below

0
On

That worked:

def questions = TestProfessional.withCriteria(uniqueResult: false) {
            answers {
            inList("id", answersIds)
        }}