-->
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.  [ 3 posts ] 
Author Message
 Post subject: Ordered many-to-many set?
PostPosted: Thu Jul 06, 2006 4:02 pm 
Regular
Regular

Joined: Thu Apr 15, 2004 1:12 pm
Posts: 55
I have a many-to-many Set mapping, and I want to order the set on a property of the associated class.

(Class Member has a Set 'categories' of class Category.. I want this set returned in order by Category.name).

I think I can't use "order-by" in the mapping, because that wants a column name in the table, which in this case is the association table. That's just not gonna work!

I could write a Comparator for class Category that does what I want, and specify it in a <set/@sort> attribute, right? Is that my only choice, or is there a better way?

Thanks a lot,
Mark


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 4:03 pm 
Regular
Regular

Joined: Thu Apr 15, 2004 1:12 pm
Posts: 55
I meant to add... I'm using Hibernate 3.1 :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 4:28 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
well, by using a comparator, the sorting is done in memory not in the db. So you can either have hibernate sort it using that comparator, or you can manually insert it into the tree set. Same thing, one just takes a little less code by you

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.