Hi community,
I'm using Hiernate 3 with Spring 2.5.5 and here is my problem:
When mapping a collection in hibernate I have no problem using a <bag> tag in my mapping file:
Quote:
<hibernate-mapping>
<class catalog="experimentdb" name="model.SetUp" table="set_up">
<id name="setUpId" type="java.lang.Integer">
<column name="set_up_id"/>
<generator class="identity"/>
</id>
<property name="date" type="timestamp">
<column length="19" name="date" not-null="true"/>
</property>
<property name="status" type="string">
<column length="32" name="status" not-null="true"/>
</property>
<bag inverse="true" name="setUpFeatures">
<key>
<column name="set_up_id" not-null="true"/>
</key>
<one-to-many class="model.SetUpFeature"/>
</bag>
</class>
</hibernate-mapping>
but if I try to use a <list> tag, the SetUpFeature collection is not loaded properly,
it contains many empity objects.
For example, if the collection should contain 3-4 elements, if I try to swith to <list> the method
public java.util.List getSetUpFeatures()
will return 18-20 elements of wich 16 will be empty.
What I do is just to substitute the <bag> tag with the following:
Quote:
<list inverse="true" name="setUpFeatures">
<key>
<column name="set_up_id" not-null="true"/>
</key>
<list-index column="set_up_feature_id" />
<one-to-many class="model.SetUpFeature"/>
</list>
I tried to use the <set> tag and it works as well, but I need a ordered without duplicates list.
Does anyone have any ideas?
Sorry for my poor english
many thanks for the help