I have to create objects and mapping to a parent/child structure for a legacy database.
In short, I have a parent object "Invoice" with a child "InvoiceRow". Both have composite id's.
INVOICE(
year, 
number, customer)
INVOICEROW(
year, 
number, 
row, item)
(underlined fields are business key members).
Hibernate version: 3.2.4.sp1 
I've tried with the following mappings, but with no success in insert and delete of childs.
Mapping documents:
Code:
<class name="Invoice" table="invoice">
   
    <composite-id name="invoiceId" class="org.test.InvoiceId">
      <key-property name="year" type="short"/>
      <key-property name="number" type="integer"/>
    </composite-id>
      
    <property name="customer" type="string" length="10"/>
      
    <set name="rowSet" cascade="all-delete-orphan" inverse="true"
        sort="org.test.RowComparator">
      <key>
        <column name="year"/>
        <column name="number"/>
      </key> 
      <one-to-many class="InvoiceRow"/>
    </set>
            
</class>
Code:
<class name="InvoiceRow" table="invoicerow">
   
    <composite-id>
      <key-many-to-one
          name="invoice"
          class="Invoice">
        <column name="year"/>
        <column name="number"/> 
      </key-many-to-one> 
      <key-property name="row" type="integer"/>
    </composite-id>
    <property name="item" type="string" length="10"/>
            
</class>
InvoiceId is the class of the Invoice identifier and is defined in a quite obvious way.
row field is assigned manually.
One of the problems is that equals and hashCode of child are defined to be a function of the index field of the child (row).
I know this is an error, but there is no other set of fields to correctly define  these methods.
Any suggestion?