[英]How to apply DISTINCT for Child Object using hibernate criteria
I have object called 'MasterObj'. 我有一个名为“ MasterObj”的对象。 In that 'MasterObj', I have a child object called 'EmployeeObj'(foreign Key)
在该“ MasterObj”中,我有一个名为“ EmployeeObj”(外键)的子对象
The relation ship between 'MasterObj' and 'EmployeeObj' is one to Many. “ MasterObj”和“ EmployeeObj”之间的关系是一对多的。
And my 'MasterObj' had so many duplicate 'employeeObj' 我的“ MasterObj”有很多重复的“ employeeObj”
I need a count of MasterObj with DISTINCT or without duplication of emp_SlNo 我需要使用DISTINCT或不重复emp_SlNo的MasterObj计数
How can I filter the duplicate emp_SlNo from my MasterObj using hibernate criteria. 如何使用休眠条件从MasterObj过滤重复的emp_SlNo。
Sorry for the my bad english. 对不起,我英语不好。
Thanks in adance. 预先感谢。
After so much of google, finally I got this code: 经过这么多的google,终于我得到了以下代码:
ProjectionList projList = Projections.projectionList();
projList.add(Projections.property("id.state"));
projList.add(Projections.property("id.uspsCity"));
criteria.setProjection(Projections.distinct(projList));
And it works fine for me. 它对我来说很好。 It eliminates the duplicate child object from parent objects.
它从父对象中消除了重复的子对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.