Grails createCriteria如何使用两个inLists()

时间:2017-01-13 07:11:12

标签: hibernate grails gorm createcriteria

我有一个域类人物,它有多个汽车和房屋:

def People {
    SortedSet<Car> cars = new TreeSet<Car>()
    SortedSet<House> houses = new TreeSet<House>()
}

def Car {
    Long id
}

def House {
    Long id
}

在grails中,我想找到id = 1的汽车和id = 1的汽车的人。

如何有效地实现这一目标?我试过这个,但它不起作用:

People.withCriteria {
    cars {
        inList('id', 1L)
    }
    houses {
        inList('id', 1L)
    }
}

这也不是因为它返回多个类似的对象:

People.withCriteria {
    createAlias('cars', c)
    createAlias('houses', h)

    inList('c.id', 1L)
    inList('h.id', 1L)
}

有人会在这里伸出援助之手吗?谢谢!

0 个答案:

没有答案
相关问题