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.  [ 4 posts ] 
Author Message
 Post subject: Sets and lists
PostPosted: Thu Oct 23, 2003 8:01 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
I'm from the RDMS school of thought and am wondering... in what cases does it make most sense to use a Set and when does it make most sense to use a List?

Are there any general rules of thumb? Can I get away with always using Sets for collections (i.e. what I think of as N-to-many relationships)


Top
 Profile  
 
 Post subject: go with sets
PostPosted: Thu Oct 23, 2003 3:48 pm 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
I almost always use Sets instead of lists. Lists have two attributes that make them unappealing to me: the listed entities have to have an entire column just for the list index value; and when you get a List instance, the elements are not ordered continuously in the list but are ordered by the index column with null values in the in between spaces.

Between Set and SortedSet I've been able to handle just about any entity model.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 3:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
bags, on the other had, are great - and don't require messing with equals()/hashCode()


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 3:48 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Could you elaborate?

In what cases would you use Set over Bag and vice versa. Are there instances where List is better than the other two?

Thanks.


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