[英]HQL: how to find item in a subcollection by id
I'm trying to find the number of Events that have a given Cluster as member. 我正在尝试查找具有给定集群作为成员的事件数。 I have the cluster id.
我有集群ID。 (Event to Cluster is a ManyToMany.)
(群集事件是ManyToMany。)
I have an HQL query like this: 我有一个像这样的HQL查询:
select count(*) from Event e join e.clusters c where :id in (c.id)
I've also tried to put a subselect in the "in" part, but no luck. 我也尝试过在“中”部分添加一个子选择,但是没有运气。
Is there a way to do this in HQL? HQL中有办法吗?
select count(distinct e.id)
from Event e join e.clusters c
where c.id = :id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.