I have a Many-to-Many relationship between a Company and Category. In the database I have a bridge table called Company_Category. My delete process for a company works. When I delete a Category I would like to delete all the corresponding rows in the bridge table along with the category.
Hibernate version: 3
Mapping documents:
Company
Code:
<hibernate-mapping package="com.bus.objects">
<class name="Company" table="Company">
<id name="companyID" column="Company_ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="companyName" column="Company_Name" type="java.lang.String" not-null="false" />
<set name="categories" table="Company_Category" inverse="false" cascade="none" outer-join="true" sort="unsorted">
<key column="Company_ID" />
<many-to-many class="Category" column="Category_ID" />
</set>
</class>
</hibernate-mapping>
Category
Code:
<hibernate-mapping package="com.bus.objects">
<class name="Category" table="Category">
<id name="id" column="Category_ID" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="categoryName" column="Category_Name" type="java.lang.String" not-null="false" />
</class>
</hibernate-mapping>