-->
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.  [ 5 posts ] 
Author Message
 Post subject: Why would anyone use a Set for mapping a collection
PostPosted: Fri Mar 20, 2009 1:25 am 
Beginner
Beginner

Joined: Sat Feb 07, 2009 12:31 am
Posts: 21
Hi,

Why would anyone use a Set for mapping a collection of an entity if Set is not going to be supported by the JSF h:dataTable?

Somebody said:

Quote:
Why are you focusing too much on using the wrong API for an ordered/indexed collection? Just use List or DataModel, then you don't need to worry about it and/or implement odd workarounds.


Are we now supposed to adjust the back-end to compensate for the front end?

References:
http://forums.sun.com/thread.jspa?threadID=5273924
http://www.icefaces.org/JForum/posts/list/4005.page

Any opinions and suggestions are welcome.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 20, 2009 4:47 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
I can't speak on why jsf uses a list, but that seems perfectly acceptable. JSF is a different library from hibernate so there really is not a correlation between the 2.


I use sets whenever appropriate. If I want unique values only for instance. It also has a small footprint then a list. As in any language you shouldn't be using something just because it's easy to use, but because it fits the situation that it's in.

Why not use a Set?

_________________
Please rate my replies as I need points for all of my questions also.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 20, 2009 5:38 pm 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
I use bag (list) on one to many if there is no natural business key, and the business can't define uniqueness. For instance if theres a unique constraint in the database over a set of columns, then a set mapping can make sense...

Nice thing about bag/list is you can cheat a bit on your equals/hashcode implementations...

J


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 21, 2009 12:26 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
hello all, i just use a list, when i want to add additional indexing to the collection and of course when it makes sense duplicate entries. I use bags when i have some legacy or simply because when i don't want to add an additional indexing column on the db. I've use the sets less frequent that the other two but it also have it's use...

regards,


ps, don't confuse JSF with Hibernate they are not the same and they are made to accomplish two different things. If u are having troubles using sets that are defined in the pojos try to pass the whole set collection to a new arraylist, after that JSF will wrap the instance of that arraylist into a datamodel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 21, 2009 10:16 am 
Beginner
Beginner

Joined: Sat Feb 07, 2009 12:31 am
Posts: 21
ethnarch wrote:
I use sets whenever appropriate. If I want unique values only for instance. It also has a small footprint then a list. As in any language you shouldn't be using something just because it's easy to use, but because it fits the situation that it's in.

Why not use a Set?


Actually I use a set, because I think it's the appropriate semantic to use in my situation (duplicates shouldn't be allowed), but what can I do if the front-end don't have any use for a Set? So what I did is I converted all my collection mappings to a list.

I just wonder about those who use Set, how do they display it on a JSF dataTable with minimal effort. Some have made a facelets tag function that converts Set to a List, but I wonder what could be the impact on it on the model if say, the dataTable displays editable rows (each row has an h:inputText), would the values entered be propagated back to each items if in case a user modified something on the table?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.