Hibernate version: 3.0.5
In Hibernate 3.0.5 is there any way to do a mapping between class A and B such that on-delete="cascade" functionality (in Oracle "ON DELETE CASCADE ENABLE") is generated in the DDL?
It would not appear to be so, since on-delete is an attribute of a <key> and <key> is not legal for <one-to-one>, unlike the situation with other forms of association (there is no collection here on either side).
Is there a workaround for this? Here is what I have. I want the generated SQL to add ON DELETE CASCADE ENABLE on B's foreign key constraint to A.
Code:
<hibernate-mapping>
<class name="A">
<id name="id" type="java.lang.Long"column="a_id">
<generator class="seqhilo">
<param name="max_lo">100</param>
<param name="sequence">a_seq</param>
</generator>
</id>
<one-to-one name="myB"
class="B"
property-ref="myA"
lazy="true"
fetch="select">
</one-to-one>
<!-- other data -->
</class>
<class name="B">
<id name="id" type="java.lang.Long" column="id">
<generator class="seqhilo">
<param name="max_lo">100</param>
<param name="sequence">_seq</param>
</generator>
</id>
<many-to-one name="myA"
column="A_id"
unique="true"
not-null="true"/>
<!-- other data -->
</class>
</hibernate-mapping>