criteria = createCriteria("employee");
criteria.add(Restrictions.eq("name", "John"));
criteria.addOrder(Order.asc("city"));
criteria.addOrder(Order.asc("state"));
List result = criteria.list();
This statement returns a list of Employee
objects. How can I make it return a Set
of Employee objects instead, in order to remove duplicate data?
I understand I can achieve this by creating a set out of the returned list like below, but then I would lose the sorting order of the list. And I don't want to have to write code to sort the set.
Set<Employee> empSet = new HashSet<Employee>(result);