本文介绍了休眠准则,以找到具有独特价值的计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下sql查询,我需要获取相应的休眠条件查询

I have the following sql query ,i need to get the corresponding hibernate criteria query

SELECT COUNT(DISTINCT employee_id) FROM erp_hr_payment WHERE payment_id IN(
SELECT payment_id FROM erp_hr_payment_collection WHERE payment_id IN(
SELECT payment_id FROM erp_hr_payment_collection WHERE payment_id IN(
SELECT payment_id FROM erp_hr_payment
 WHERE for_month BETWEEN '2013-04-01' AND '2014-03-31' AND arrear_flag=0
) AND element_name='EPF' ) AND element_name='EPFV');

推荐答案

从大多数内部查询开始,创建相对的DetachedCriteria并使用Subqueries.in()附加到外部查询.
对于count(distinct),请使用Projections.countDistinct(propertyName).享受.

Begin from most inner query create relative DetachedCriteria and attach to outer query using Subqueries.in().
For count(distinct) use Projections.countDistinct(propertyName).Enjoy.

这篇关于休眠准则,以找到具有独特价值的计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 20:27