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: Using List in place of Set for one to many and many to many
PostPosted: Fri Aug 19, 2005 12:26 pm 
Newbie

Joined: Fri Aug 19, 2005 12:16 pm
Posts: 1
Traversing List through Index is definitely faster than the Iterator over Set, and the implementation of List to achieve many to many relationship notion in Hibernate is also achievable, however the List implementation does skew the association table semantics since you have to define index column in association table through index column directive in List segment which is bound to association table. From a Database perspective this index column does not make sense (Association table in DB for many to many relationship assumes you have two columns which are primary keys to the referencing tables and that's it). If a DBA takes a look at the association table created by Hibernate through List implementation, he will in a state of shock and awe.

So The question is ...
Does it make sense to skew the association table notation in DB for sme performance gain by using List in place of Set and if yes why didn't Gavin King discussed on this topic till now.

All the reference docs in Hibernate 3 advocates to use Set for many to many relationship.

I have implemented the List for many to many relationship in some projects, but it does not make me feel better, may be because I am an ardent DB developer also...Can someone mitigate my intellectual pain by commenting on the above...


<list name="benchmarks" table="Institutions_Benchmarks" inverse="true">
<meta attribute="field-description">benchmarks for this institution</meta>
<key column="INSTITUTION_ID"/>
<index column="col_idx"/>
<many-to-many class="Benchmark" column="BENCHMARK_ID"/>
</list>

vs

<set name="systemtypes" table="Institutions_SystemTypes" inverse="true">
<meta attribute="field-description">system types for this institution</meta>
<key column="INSTITUTION_ID"/>
<many-to-many
class="SystemType"
column="SYSTEMTYPE_ID"/>
</set>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 19, 2005 2:28 pm 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
You should be able to use bag semantics with many-to-many, which is essentially a List with no guaranteed ordering. If you need to order the components of the List, then you must specify an order-by attribute (SQL column list) or a sort attribute (Comparator implementation).


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.