Hibernate version: 3.0.5
Name and version of the database you are using:Oracle9i
Hi,
how can I map a bidirectional, one-to-many parent-child relationship, so that the order of the children will be preserved (we use now java.util.List collection for the children, but it can be changed) and a 'delete on cascade' constraint applies?
I use the
following mapping now, but the column ROW_NO isn't filled in the database after saving the objects:
Parent (simplified version):
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field">
<class name="de.gabo.converter.common.data.rackdesign.DRackDesign"
table="CON_RD_RACKDESIGN">
<id name="m_id" column="ID">
<generator class="sequence">
<param name="sequence">SEQ_RD_RACKDESIGN</param>
</generator>
</id>
<component name="m_codeNumber">
<property name="m_sOrderNumber">
<column name="CODENUMBER" length="25" not-null="true"/>
</property>
</component>
<property name="m_projectName">
<column name="PROJECTNAME" length="64"/>
</property>
<property name="m_remark">
<column name="REMARK" length="4000"/>
</property>
<list name="m_wireList" fetch="join" cascade="all-delete-orphan" lazy="true" inverse = "true">
<key column="RACKDESIGN_ID" on-delete="cascade"/>
<list-index column="ROW_NO"/>
<one-to-many class="de.gabo.converter.common.data.rackdesign.DWire"/>
</list>
</class>
</hibernate-mapping>
Child (simplified version):
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field">
<class name="de.gabo.converter.common.data.rackdesign.DWire"
table="CON_RD_WIRE">
<id name="m_ID" column="ID">
<generator class="sequence">
<param name="sequence">SEQ_RD_WIRE</param>
</generator>
</id>
<component name="m_codeNumber">
<property name="m_sOrderNumber">
<column name="ORDERNUMBER" length="25"/>
</property>
</component>
<property name="m_remark">
<column name="REMARK" length="23"/>
</property>
<many-to-one name="m_rackDesign" index="ROW_NO" not-null="true">
<column name="RACKDESIGN_ID"/>
</many-to-one>
</class>
</hibernate-mapping>
thank you,
torel