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?