【问题标题】:Subselect, Group by and Having Count with criteria in hibernate在休眠中使用条件进行子选择、分组和计数
【发布时间】:2019-08-21 04:01:20
【问题描述】:

我有一个这样的查询:

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;

如何使用条件编写此查询?

【问题讨论】:

    标签: sql hibernate criteria hibernate-criteria detachedcriteria


    【解决方案1】:

    无法从与实体不匹配的子选择中创建子标准。

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

    上述查询与任何实体都不匹配,因此无法从中创建子条件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-17
      • 2012-02-12
      • 1970-01-01
      • 2019-02-19
      • 1970-01-01
      • 2011-05-05
      • 2012-12-09
      • 1970-01-01
      相关资源
      最近更新 更多