Joined: Fri Feb 20, 2004 2:33 pm Posts: 3 Location: Valencia, Spain
|
Hi, maybe this is easily solved but I can't find any information:
I am progamming a website with categories. Each category shall
have a map/list of related categories. So I wrote a class category
with Map relatedCategories and provided the following mapping:
Mapping document:
<hibernate-mapping>
<class name="Category" table="Category"
entity-name="Category">
<id name="id" column="CategoryID">
<generator class="native" />
</id>
<property name="name" column="CategoryName"/>
<property name="icon" column="CategoryIcon"/>
<property name="description" column="CategoryDescription"/>
<property name="siteID" column="SiteID"/>
<map name="relatedCategories" table="CategoryMapping" lazy="true" cascade="all">
<key column="CurrentCategoryID"/>
<index column="KeyName" type="string"/>
<many-to-many column="RelatedCategoryID" class="Category"/>
</map>
</class>
</hibernate-mapping>
So this means that I have a mapping table CategoryMapping that
maps a category CurrentCategory with a map of Relatedcategories.
Adding, modifying and removing related categories works fine.
But what if I delete a category which is a relatedCategory of one or
more other categories? How can I tell hibernate to remove all
rows of CategoryMapping whose foreign key RelatedCategoryID points to the removed category?
|
|