-->
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: Getting Hibernate to return results in order
PostPosted: Tue Aug 15, 2006 1:35 pm 
Newbie

Joined: Mon Jul 24, 2006 3:21 pm
Posts: 14
I'm using Hibernate in my current project. I have a class TreeNode that has a Set<TreeNode> getChildren() method. I would like to somehow convert this to something like List<TreeNode> getChildren() and make sure the list is returned in order as determined by the getName() value of each TreeNode. I realize that I could code up the getChildren method myself, returning an ordered List, but I would like to see if Hibernate can do it all behind the scenes first.

1. Is this possible?
2. If so, any quick tips?
3. Do I need to tell me underlying DB that I want collation based on the Name column or is the solution achieved using only Hibernate features?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 15, 2006 6:06 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
You don't need to use a list to do this. Just make your set ordered. The <set> element supports both the sort="" and order-by="" attributes. Check out the refdocs to see what they do.

_________________
Code tags are your friend. Know them and use them.


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.