Hibernate version:
3.0
Mapping documents:
Code:
<hibernate-mapping>
<class
name="com.tougher.intranet.employee.unit.Unit"
table="Unit">
<id
name="unitCode"
column="unitCode"
type="java.lang.Long">
<generator class="native">
</generator>
</id>
<property
name="unitName"
type="java.lang.String"
update="true"
insert="true"
column="unitName"/>
<many-to-one
name="superUnit"
class="com.tougher.intranet.employee.unit.Unit"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="superUnitCode"/>
<set
name="subUnits"
lazy="false"
cascade="none"
sort="com.tougher.intranet.employee.unit.Unit">
<key
column="superUnitCode">
</key>
<one-to-many
class="com.tougher.intranet.employee.unit.Unit"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
I have a recursive relationship... Units associated to superUnits.
When I delete a unit that is a superUnit of other units,
what happens is that the unit is deleted and the subUnit's referenece column becomes null...
Is this is the expected behavior?
What should I change in my mapping.xml file to prevent delete if there are still objects associated to the object in question?
thanks.