I have the following Parent Child Relationship involving two
tables/entities. Group(Parent) and User(Child). The Mapping is as follows.
Now there is a requirement where I have to delete a Group entry from the
parent table when the last last child i.e. User entry of that particular
Group is deleted from the child table. I added cascade=delete in the child
table but that is not giving correct result. Any possible other solution?
*Parent Table:*
<class name="Group" table="Group" lazy="true" >
<id name="Id">
<generator class="identity /">
</id>
<property name="Name">
<column name="Name" sql-type="nvarchar" not-null="true" />
</property>
* <bag name="Users" inverse="true" cascade="all">
*
* <key column="GroupId" />*
* <one-to-many class="Group" />*
* </bag>*
</class>
*Child Table:*
<class name="User" table="User" lazy="false" >
<id name="Id">
<generator class="identity" />
</id>
<property name="FirstName">
<column name="FirstName" sql-type="nvarchar(MAX)" not-null="true" />
</property>
...............................
...............................
* <many-to-one update="false" not-null="true" **name="Group"> // added
cascade delete here but that is not working*
* <column name="GroupId" />*
* </many-to-one>*
</class>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/2sZYxy9dJBYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.