Hi,
I turned on cascade="all-delete-orphan" and it now throws an exception
Quote:
You may not dereference a collection with cascade="all-delete-orphan"
I have not changed anything else except the cascade for Department
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.infosys.j2ee.cmptest.model.Department" table="DepartmentEJBTable">
<id name="primaryKey">
<generator class="sequence">
<param name="sequence">test2_seq</param>
</generator>
</id>
<property name="name">
<column name="NAME"/>
</property>
<property name="location">
<column name="LOCATION"/>
</property>
<bag name="employees" inverse="true" outer-join="true" cascade="all-delete-orphan">
<key column="departmentid"/>
<one-to-many class="com.infosys.j2ee.cmptest.model.Employee"/>
</bag>
</class>
<class name="com.infosys.j2ee.cmptest.model.Employee" table="EmployeeEJBTable">
<id name="primaryKey">
<generator class="sequence">
<param name="sequence">test2_seq</param>
</generator>
</id>
<property name="name">
<column name="NAME"/>
</property>
<property name="employeeNumber">
<column name="EMPLOYEENUMBER"/>
</property>
<property name="hireDate">
<column name="HIREDATE"/>
</property>
<property name="salary">
<column name="SALARY"/>
</property>
<many-to-one name="department" class="com.infosys.j2ee.cmptest.model.Department" column="departmentid" cascade="all"/>
</class>
</hibernate-mapping>