I donβt think you can return Set using javadoc-based Criteria . However, if you want to remove duplicate data, why not add Projections.distinct(...) to your existing Criteria to remove duplicates?
http://docs.jboss.org/hibernate/envers/3.6/javadocs/org/hibernate/criterion/Projections.html
UPDATE
For example, if you want to apply SELECT DISTINCT to an employee name (or some identifier) ββto get a list of unique employees, you can do something like this: -
List result = session.createCriteria("employee") .setProjection(Projections.distinct(Projections.property("name"))) .add(Restrictions.eq("name", "John")) .addOrder(Order.asc("city")) .addOrder(Order.asc("state")) .list();
Thus, you do not need to worry about using Set at all.
source share