I'm continuing to examine the possibility of preventing casades when
deleting the parent. And now I've run into something that has got me
totally stumped! I have a simple forum with topics, here's my mapping
Forum:
<bag name="Topics" table="tblForumTopic" lazy="true" inverse="true"
cascade="save-update, delete-orphan">
<key column="ForumId" on-delete="cascade" />
<one-to-many class ="ForumTopic"/>
</bag>
Topic:
<many-to-one name="Forum" class="Forum" column="ForumId"
cascade="none" />
When I do a Session.Delete(forum) only one delete statement is fired
(according to nhibernate profiler) "delete from tblforum where id =
X". However the topics are also deleted and are even audited in my
audit implementation which hooks to the event postdelete.
I guess I could set inverse="false" (but then I can't use on-delete
cascade) on forum and I should probably also use a set and not a bag,
but I still don't understand this.
Here's a screenshot from profiler:
http://tinypic.com/view.php?pic=ephbi1&s=7
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
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.