问题
Hi i want to write a query using criteria : The following query has to be created using criteria:
"Select Distinct(s2Taxper) from S2 where s2Tc='601' AND s2Txcd!=''"
thanks in advance
回答1:
Criteria criteria =
session.createCriteria(S2.class)
.add(Restrictions.eq("s2Tc","601"))
.add(Restrictions.ne("s2Txcd",""))
.setProjection(Projections.distinct(Projections.property("s2Taxper")));
来源:https://stackoverflow.com/questions/12032748/hibernate-criteria-projection-distinct