Grails 在HQL中获取两个集合的交集
我的HQL有点问题 我想做一个相当复杂的查询,我有以下域对象(简化): 基本上我想要这样的东西(这是不可能的): 顺便说一句,这是我正在从事的grails项目,但我想在HQL中解决这个问题 有什么想法吗?试试这个:Grails 在HQL中获取两个集合的交集,grails,collections,hql,gorm,Grails,Collections,Hql,Gorm,我的HQL有点问题 我想做一个相当复杂的查询,我有以下域对象(简化): 基本上我想要这样的东西(这是不可能的): 顺便说一句,这是我正在从事的grails项目,但我想在HQL中解决这个问题 有什么想法吗?试试这个: select o from Object as o join o.otherObjects as otherObject where otherObject in :allowedotherobjects and otherObject not in :exc
select o from Object as o
join o.otherObjects as otherObject
where
otherObject in :allowedotherobjects
and otherObject not in :excludedotherobjects
另一个选项是从其他对象进行查询,这会更简单。这似乎不起作用,就像“和其他对象不在:excludedotherobjects”部分没有做任何事情一样。如何从otherObject执行查询?
select o from Object as o
join o.otherObjects as otherObject
where
otherObject in :allowedotherobjects
and :excludedotherobject not in elements(o.otherObjects)
select o from Object as o
join o.otherObjects as otherObject
where
otherObject in :allowedotherobjects
and elements(:excludedotherobjects) not in elements(o.otherObjects)
select o from Object as o
join o.otherObjects as otherObject
where
otherObject in :allowedotherobjects
and otherObject not in :excludedotherobjects