-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: DistinctRootEntityResultTransformer mangling my order?
PostPosted: Wed Feb 15, 2006 2:51 pm 
Newbie

Joined: Wed Feb 15, 2006 2:11 pm
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 12:13 pm 
Newbie

Joined: Wed Feb 15, 2006 2:11 pm
Posts: 2
I see lots of views, but no replies. Anybody have some ideas? Is this a bug, or am I not applying the code correctly? Should I not expect my ordering to work in this case?

thanks,
-scott


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.