Hi there,
I am trying to fill an array with child objects in a db table and having no luck. The problem is I dont have a field in the database table that is zero-based so the <list-index> is pointing just to the primary key in the child table. Problem is it is not zero based per parent.
Here is the problem. Person has an array of Addresses.
class Person{
private int personid;
Address [] addresses;
}
class Address {
private int addressId;
private int personId;
}
My mapping is:
<class="Person">
<array name="addresses"
cascade="all-delete-orphan">
<key column="personId"/>
<list-index column="id"/>
<one-to-many class="com.company.Address"/>
</array>
</class>
<class="Address">
<id name="id" type="integer">
<column name="id" />
<generator class="native" />
</id>
<property name="personId" type="integer" insert="false" update="false">
<column name="personId" not-null="true" />
</property>
</class>
The problem, again, is that the <list-index> will be something like 4578 for the child address row. I get an arrayindexoutofboundsexception of course.
How can i make this work?
|