Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
2.0.1.4
Mapping documents:
Multiple mapping files
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<class name="FlexiCommerce.Components.PersistenceItem,FlexiCommerce" table="FlexiItem">
<cache usage="read-write" />
<id name="ID" column="ID" type="Int32" unsaved-value="0" access="property">
<generator class="native" />
</id>
<discriminator column="Type" type="String" />
<property name="Name" access="property" length="255" />
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<subclass name="FlexiCommerce.Components.Category,FlexiCommerce" extends="FlexiCommerce.Components.PersistenceItem,FlexiCommerce" discriminator-value="Category" lazy="false">
<bag name="Products" lazy="false" generic="true" table="Flexi_ProductCategoryMapping" inverse="true">
<cache usage="read-write" />
<key column="ID2"></key>
<many-to-many class="FlexiCommerce.Components.Product,FlexiCommerce" column="ID"></many-to-many>
</bag>
</subclass>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
<subclass name="FlexiCommerce.Components.Product,FlexiCommerce" extends="FlexiCommerce.Components.PersistenceItem,FlexiCommerce" discriminator-value="Product" lazy="false">
<bag name="Categories" generic="true" lazy="false" table="Flexi_ProductCategoryMapping">
<cache usage="read-write" />
<key column="ID"></key>
<many-to-many class="FlexiCommerce.Components.Category,FlexiCommerce" column="ID2"></many-to-many>
</bag>
</subclass>
</hibernate-mapping>
What I'm trying to do.
Right now, when I delete a category, all the referenced products get delete, and all the categories referencing those products get deleted. What ends up happening is every category and product record in my database gets deleted.
What I would like to happen is when I delete a category or product, nothing else gets deleted. I set cascade="none" so the referenced items wouldn't inherit the deletes and it says it can't delete due to an enforced foreign key relationship (the many-to-many mapping table).
How do I get it so that when I delete a category or product, nothing else gets deleted besides all of its mappings in the mapping table?