I start to think that it's not possible at all, but I need to ask for it.
Imagine a website like DMOZ with a lot of categories each category is an instance of Category class persisted by Hibernate.
Mapping for children could looks like:
<hibernate-mapping>
<class name="com.test.Category" lazy="true" >
....
<many-to-one name="parent" column="CatParent" cascade="none" />
<set name="children" cascade="all-delete-orphan" inverse="true" lazy="true" batch-size="10">
<key column="CatParent" on-delete="cascade" />
<one-to-many class="com.test.Category" />
</set>
...
</class>
</hibernate-mapping>
I try to build several lvls tree eg Level 0, Level 1, Level 2, Level 3, Level 4 and delete Level 1 as I have used all-delete-orphan I thought that whole branch with Level 2, Level 3, Level 4 would be erased but Hibernate only did "Hibernate: delete from category where CatID=?", without deleting rest of Objects - is there any way to delete all objects starting from parent Object and traverse "down" on every child (I mean without self coding this traversing?)
Regards Lee
|