Hi!
Please, I'm trying to map many-to-many association in order to use cascading Delete.
Model Description: A View contains a List of Group (using the DB Association Table Asso_Project_Manager_Group_View). And a Group contains a List of Project Manager (using the DB Association Table Asso_Project_Manager_Group).
Find below Mapping Files:
ProjectManagerStatViewVO (or View):
<class name="EJL.ORM.Entity.ProjectManagerStatViewVO, ORM" table="STAT_PROJECT_MANAGER_VIEW" >
<id name="id" access="field" column="ID" type="System.Int32" unsaved-value="0">
<generator class="native"/>
</id>
<property name="label" column="LABEL" access="field" not-null="true" type="System.String" length="250" insert="true" update="true"/>
<bag name="groupList" access="field" lazy="false" table="ASSO_PROJECT_MANAGER_GROUP_VIEW" cascade="all">
<key column="VIEW_ID"/>
<many-to-many column="GROUP_ID"
class="EJL.ORM.Entity.ProjectManagerStatGroupVO, ORM"/>
</bag>
</class>
ProjectManagerStatGroupVO (or Group)
<class name="EJL.ORM.Entity.ProjectManagerStatGroupVO, ORM" table="STAT_PROJECT_MANAGER_GROUP" >
<id name="id" access="field" column="ID" type="System.Int32" unsaved-value="0">
<generator class="native"/>
</id>
<property name="label" column="LABEL" access="field" not-null="true" type="System.String" length="250" insert="true" update="true"/>
<bag name="projectManagerList" access="field" lazy="false" table="ASSO_PROJECT_MANAGER_GROUP" cascade="all">
<key column="GROUP_ID"/>
<many-to-many column="PROJECT_MANAGER_ID"
class="EJL.ORM.Entity.ProjectManagerVO, ORM"/>
</bag>
Save and Update directly View work perfectly (Hibernate create View, Groups and all links in one Method Call). Now, I would like to Delete a View using session.Delete(view). Currently, it seems NHibernate is trying to delete all instances, also ProjectManager instances and this throws Constraint Violation Exception since ProjectManager are referenced by other entities. How I can Specify to NHibernate it should delete all instances except ProjectManager instances ?
Thanks in advance. Jonathan