【发布时间】:2011-05-23 00:31:46
【问题描述】:
我想检查一个集合 (u.organisations) 的至少一个元素是否包含在另一个集合中 (? = excludeOrganisations):
select distinct u from SystemUser u
join u.userGroups g
join u.organisations o
where 3 in elements(g.permissions) and
EACH_ELEMENT_OF(o) not in (?)
如何用 HQL 表达EACH_ELEMENT_OF?
我的最后一次试验是:
select distinct u from SystemUser u
join u.userGroups g
where 3 in elements(g.permissions) and
not exists (
select org from Organisation org
where org in elements(u.organisations)
and org not in (?)
)
但我得到了例外:
IllegalArgumentException occurred calling getter of Organisation.id
【问题讨论】:
-
嘿,你在这方面有什么进展吗?
-
我的解决方法是使用 for 循环,这可以通过相对较少的元素实现。
-
尝试传入一个组织列表,而不是一个仅包含其 ID 的列表。我已经尝试过类似的方法,并且成功了。
标签: hibernate collections hql