簡體   English   中英

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)

我也嘗試過在“中”部分添加一個子選擇,但是沒有運氣。

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM