-->
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: Best way to convert from a Set to an OrderedList
PostPosted: Wed Apr 08, 2009 11:46 pm 
Beginner
Beginner

Joined: Sun Nov 07, 2004 4:19 pm
Posts: 38
Can anyone give the best way to upgrade from a one-to-many relationship type as a Set to a an OrderedList list using the list-index field.

I added the position column (the list-index field) and defaulted the value to 0. However, hiberate will only return one value if there are two items with the same position value. Is there an sql I can write as an upgrade or a flag to hibernate to handle this situation?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 09, 2009 8:32 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
I'm not really answering your question but if it's worth anything to you, if you put the "order-by" in the mapping file you can continue to use a Set. Hibernate will use a LinkedHashSet, which is ordered. But you'd still need to keep proper values (unique natural numbers) in a db column

_________________
Chris

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 09, 2009 10:16 am 
Beginner
Beginner

Joined: Sun Nov 07, 2004 4:19 pm
Posts: 38
[quote="kochcp"]I'm not really answering your question but if it's worth anything to you, if you put the "order-by" in the mapping file you can continue to use a Set. Hibernate will use a LinkedHashSet, which is ordered. But you'd still need to keep proper values (unique natural numbers) in a db column[/quote]

We were thinking of doing this but the linkage table is being maintained by hibernate and there's no corresponding POJO. The advantage of using list-index is that it is maintained by hibernate automatically.


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.