HQL:如何通过 id 在子集合中查找项目

HQL: how to find item in a subcollection by id

我正在尝试查找将给定集群作为成员的事件数。我有集群 ID。 (事件到集群是 ManyToMany。)

我有一个这样的 HQL 查询:

select count(*) from Event e join e.clusters c where :id in (c.id)

我也试过在 "in" 部分添加子选择,但没有成功。

有没有办法在 HQL 中做到这一点?

select count(distinct e.id) 
from Event e join e.clusters c 
where c.id = :id