-->
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: Change type of relationship list
PostPosted: Tue Nov 16, 2010 8:36 am 
Beginner
Beginner

Joined: Tue Jan 19, 2010 7:11 am
Posts: 23
Location: Spain
I would like to change the type of the attribute generated from a relationship from "Set" to "List".

from (default):
private Set<XXX> xxxs;


To (customize):
private List<XXX> xxxs;


Thanks.


Top
 Profile  
 
 Post subject: Re: Change type of relationship list
PostPosted: Fri Nov 26, 2010 7:59 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
The other answer would be: why do you want this?
You can iterate over a Set with a foreach construct just fine.

If you're having problems with ConcurrentUpdateExceptions, you need to create a copy of the set anyway, using List won't reliably prevent the ConcurrentUpdateExceptions. (LinkedList should have a constructor that takes any Collection, creating such a copy. Any other Collection descendant should have the same. Or you could use Set#toArray().)

If you wish to have the related entities in a given repeatable order, using a List would establish that, but you'll usually get some random order. You'd either use a Criteria query with an ordering options, which will return a List just fine, or you'd place the Set elements in an array and sort that using a Comparator object.
(There is no "natural" order on related entities. The system doesn't know which of the many possible ways to define an ordering is the one that you want. That's why you usually need Order By, or Comparator, or some other way to establish an ordering; it's rare that the implicit ordering is indeed enough.)


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.