休眠删除 [英] hibernate deletion
问题描述
当我删除课程对象时,我希望相关的一组教程和应用程序被删除。
我的course.hbm如下所示:
和我的application.hbm包含
< property name =appdatetimetype =timestamp>
< column name =appdatetimelength =19/>
< / property>
< property name =appstatustype =java.lang.Integer>
< column name =appstatus/>
< / property>
< property name =apptypetype =java.lang.Integer>
< column name =apptype/>
< / property>
< / class>
设置cascade =delete-orphan,all,删除操作将级联到教程和应用程序,并将它们删除,如果它们是孤立的(未连接到任何其他课程)。
我们使用hibernate注释,因此我不确定要添加的确切xml,但是从文档看来,cascade =all-delete-orphan应该位于每个这些集合定义。
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" />
</class>
Set the cascade="delete-orphan,all" and the delete operation will cascade down to the tutorials and applications and delete them as well if they're orphaned (not connected to any other course).
We use hibernate annotations, so I'm not really sure the exact xml to add, but from the docs, it looks like cascade="all-delete-orphan" should be on each of those collection definitions.
这篇关于休眠删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!