| 
					
						 Hibernate version: 
 3.0.5 and 3.1.2
 
 I have the following code:
 result = session.createCriteria(Services.class)
 .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
 .setFetchMode("ports", FetchMode.JOIN)
 .createAlias("ports", "p")
 .addOrder(Order.asc("name"))
 .addOrder(Order.asc("p.portNumber"))
 .list();
 
 Basically I have a Services class that has an ID, name, description, and a set of ports.  This query eagerly fetches the collection of port objects that is associated with a service.  This would result in duplicate service rows being returned, so I apply the DISTINCT_ROOT_ENTITY result transformer.  I want the results to be ordered by service name first, and the ports for each service to also be ordered.  I think my query above should achieve this.  The problem is, the resulting port order still appears to be random.  Is this because the DistinctRootEntityResultTransformer uses a HashSet to remove the dups?
 
 Oh yeah, the name property of Services is a String and the portNumber property of Ports is an Integer.  So there shouldn't be any problem with equals/hashcode/compare.
 
 Let me know if I'm out to lunch on this one.
 
 -scott 
					
  
						
					 |