i have one course class and one tutorials class. I couse class i hav a set of tutorials. When i delete course i want the set of tutorials associated with that course aslo to be deleted. when i try to delete couse only the foreign key cid in tutorial table become null but all othere fields of tutorials tabel r intact i course.hbb.xml contains <set cascade="delete,delete-orphan,all" name="tutorials" order-by="created_date desc"> <key column="cid"/> <one-to-many class="org.psl.cms.DAO.Tutorials"/> </set>
and tutorials.hbm.xml contains
<hibernate-mapping> <class catalog="CMS" name="org.psl.cms.DAO.Course" table="course"> <id name="cid" type="int"> <column name="cid"/> <generator class="increment"/> </id> <property name="cname" type="string"> <column length="50" name="cname"/> </property> <property name="details" type="string"> <column length="300" name="details"/> </property> <property name="trainer" type="string"> <column length="50" name="trainer"/> </property> <property name="startdate" type="date"> <column length="10" name="startdate"/> </property> <property name="enddate" type="date"> <column length="10" name="enddate"/> </property> <property name="lastregdate" type="date"> <column length="10" name="lastregdate"/> </property> <property name="lastdregdate" type="date"> <column length="10" name="lastdregdate"/> </property> <property name="noseats" type="java.lang.Integer"> <column name="noseats"/> </property> <set cascade="delete-orphan,all" inverse="true" name="applications" order-by="apptype desc,appdatetime asc "> <key column="cid"/> <one-to-many class="org.psl.cms.DAO.Application"/> </set> <set cascade="delete-orphan,all" name="prerequisite"> <key column="cid"/> <one-to-many class="org.psl.cms.DAO.Prerequisite"/> </set> <set cascade="delete,delete-orphan,all" name="tutorials" order-by="created_date desc"> <key column="cid"/> <one-to-many class="org.psl.cms.DAO.Tutorials"/> </set> <set name="parentpost" cascade="all" order-by="ppid asc"> <key column="cid"/> <one-to-many class="org.psl.cms.DAO.Parentpost"/> </set> <set name="accepted_application" where="apptype =2 "> <key column="cid"/> <one-to-many class="org.psl.cms.DAO.Application"/> </set> </class> </hibernate-mapping>
|