Hibernate criteria projection distinct

criteriahibernate

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

Best Answer

Criteria criteria = 
    session.createCriteria(S2.class)
           .add(Restrictions.eq("s2Tc","601"))
           .add(Restrictions.ne("s2Txcd",""))
           .setProjection(Projections.distinct(Projections.property("s2Taxper")));