-->
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.  [ 3 posts ] 
Author Message
 Post subject: <set> vs <list> mapping
PostPosted: Mon Feb 02, 2004 8:14 am 
Newbie

Joined: Fri Jan 30, 2004 12:17 pm
Posts: 2
If I use the following one-to-many association I'm getting the expected results, e.g. 2 elements:

Code:
<set name="child" inverse="true" cascade="all">
  <key column="parentId"/>
  <one-to-many class="Child"/>
</set>


Changing the mapping from <set> to <list> as follows:

Code:
<list name="child" cascade="all">
  <key column="parentId"/>
  <index column ="lfd"/>
  <one-to-many class="Child"/>
</list>


I'm getting a list with 2 elements – as shown by the debugger – but invoking myList.size() the result is 3 .

Adding the received list to a new empty ArrayList the results are identical.

Adding the received list to a new empty LinkedList the debugger shows 3 elements the first one being null.

In any case I have to drop the first element with list.remove(0) in my program to get the same results as with the <set> mapping.

With the <set> as well as in the <list> mapping the mapping of the Child class is as follows:

Code:
<class name="Child" table="CHILD">
  <id name="id" type="long" column="ID">
    <generator class="native"/>
  </id>
  <many-to-one name="parentId" class="Parent" not-null="true"/>
  <property name="lfd" column="LFD" type="integer"/>
  ...[more properties]
class>


I'm using
- jdk 1.4.2 with Hibernate 2.1.1. in NetBeans 3.5.1
- MySQL 3.23.51 with JDBC driver MySQL Connector/J 2.0.14

Is anything wrong with my tools or did I make a mistake in my mappings?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 8:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I suspect your index column doesn't start with 0


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 8:53 am 
Newbie

Joined: Fri Jan 30, 2004 12:17 pm
Posts: 2
You are right.

Thank you very much.


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