在休眠中使用标准进行子选择、分组和计数

Subselect, Group by and Having Count with criteria in hibernate

我有这样的查询:

SELECT ap.person_id FROM 
     (SELECT distinct ac.person_id person_id,ac.user_id 
      FROM zrm_actor ac WHERE ac.deleted != 1) ap 
WHERE person_id IS NOT NULL 
GROUP BY person_id HAVING COUNT(*) > 1;

我如何编写带有条件的查询?

无法从不匹配实体的 sub-select 创建 sub-criteria。

SELECT distinct ac.person_id person_id,ac.user_id 
 FROM zrm_actor ac WHERE ac.deleted != 1

以上查询与任何实体都不匹配,因此无法从中创建 sub-criteria。