Search code examples
grailshqlgrails-orm

Grails querying the database against a list of objects


I'm creating an application with Grails.

I have two domain classes:

parent and child:

class Parent {
    string name


    hasMany[children: child]
}

class Child {
    string name

    belongsTo[parent: parent]
}

I search for all the parents with a name similar to a keyword:

def parents = Parent.findAll("From Parent as parent where parent.name like '%fra%'")

I'd like to query the database searching for all children that have a parent in the parents list.

How I could I accomplish that ?

Thanks


Solution

  • Does:

    Child.findAllByParentInList( parents )
    

    do it?