views:

67

answers:

1

i have a course object. The course object has a set of tutorials and a set of applications. When i delete a course objects i want the assocated set of tutorials and applications to get deleted. My course.hbm is as follows

and my application.hbm contains

<property name="appdatetime" type="timestamp">
    <column name="appdatetime" length="19" />
</property>
<property name="appstatus" type="java.lang.Integer">
    <column name="appstatus" />
</property>
<property name="apptype" type="java.lang.Integer">
    <column name="apptype" />
</property>

<many-to-one name="course" column="cid"/>
<many-to-one name="employee" column="empid" />

+2  A: 

In your course object you need to set the cascade option on what I presume will be a bag or similar with a one-to-many inside.

<bag name="Tutorials" cascade="all-delete-orphan">
   <key column="someId" />
   <one-to-many class="Tutorial" not-found="ignore" />

Hope this helps.

Mark Dickinson
I think it should be cascade="all,delete-orphan"
Mark