I have a domain class People, which has multiple cars and houses:
def People {
SortedSet<Car> cars = new TreeSet<Car>()
SortedSet<House> houses = new TreeSet<House>()
}
def Car {
Long id
}
def House {
Long id
}
In grails, I would like to find people who have car with id = 1, and house with id = 1.
How do I achieve this efficiently? I have tried this but it doesn't work:
People.withCriteria {
cars {
inList('id', 1L)
}
houses {
inList('id', 1L)
}
}
Neither does this as it return multiple similar objects:
People.withCriteria {
createAlias('cars', c)
createAlias('houses', h)
inList('c.id', 1L)
inList('h.id', 1L)
}
Will anyone lend a hand here? Thanks!