-->
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: Mapping collections as Set ot as List
PostPosted: Thu Jul 13, 2006 4:20 am 
Newbie

Joined: Tue Jul 11, 2006 4:22 pm
Posts: 9
Hi i have a simple question.

I have a next siplme mapping fragment

Code:
<set name="contactdoctorSet" inverse="false">
            <key column="doctor_id"/>
            <one-to-many class="Contactdoctor"/>
        </set>


I'm using in my domain objects Set as collection object for contactdoctorSet as follows :

Code:
public abstract class AbstractDoctor
    implements Serializable
{

/** The value of the contactdoctorSet one-to-many association. */
    private java.util.Set contactdoctorSet;

}


My question is : is possible to use List interface ?

Code:
private java.util.List contactdoctorSet;


is any difference for hibernate to use List or Set ? Or better is possible to use List instead of Set ? If no why ?

Thanks for help


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 4:27 am 
Newbie

Joined: Tue Jul 11, 2006 9:47 am
Posts: 19
If I am not mistaken you can use a java.ult.List contactdoctorSet (or perhaps contactdoctorList) but then your mapping would change too and would probably need to be <list ...... /> however with the list it creates a index_column in your database. You can avoid that by using <bag ..../> in your mapping which is just an un-indexed list.

There are slight performance differences with a List and a Set

Table 7.2. Relative Collection Performance
. Keys Indexed Lazy Insert Update Delete

Bag No No Yes High Poor Poor

List No Yes Yes Medium High Medium

Set No No No Medium High Medium


Hope this helps...


Top
 Profile  
 
 Post subject: set vs list
PostPosted: Thu Jul 13, 2006 4:37 am 
Newbie

Joined: Tue Jul 11, 2006 4:22 pm
Posts: 9
one more question about performance.

those values you had wrote r about java virtual machine or about how hibernate is working witch these types ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 13, 2006 5:11 am 
Newbie

Joined: Tue Jul 11, 2006 9:47 am
Posts: 19
I am not 100% sure, it simply says

The feature set shown has both functional implications and performance implications. Table shows a rough guide to the relative performance of the different collection types.


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.