I have three tables: MENU, PERMISSION, and MENUPERMISSION. MENU contains menu options for a website, PERMISSION contains permissions users can possess, and MENUPERMISSION simply has columns MENUID and PERMISSIONID to represent the association of a certain permission with a certain menu option.
I want to create a many-to-many relationship in the PERMISSION hbm that will cascade delete to MENUPERMISSION but not MENU. That way when the admin user deletes a permission, all rows in MENUPERMISSION with the given PERMISSIONID will be deleted, but the associated MENU objects themselves will not be deleted. I've tried this:
Code:
<set name="menusAssociatedWithPermission" table="MENUPERMISSION" cascade="delete">
<key column="PERMISSIONID"/>
<many-to-many class="Menu" column="MENUID"/>
</set>
I've tried it with cascade="delete", cascade="delete-orphan", and cascade="all,delete-orphan", and each time, all relevant objects from all three tables (including MENU) get deleted. What am I doing wrong?
Thanks,
Erica