If you execute the SchemaExport operation of nhibernate. it will create the
trigger automatically.

This is the only purpuse of on-delete="cascade".
keep in mind that it is an just optimization to cascade="delete" (or
cascade="all"). Cascade delete means that all topics are deleted when you
delete the forum. If you don't use on-cascade="delete" nhibernate will
execute another command (delete from topics where forumId = forumid being
deleted). But if you want the behavior of on-cascade="delete" you should
write boths:

<bag name="Topics" table="tblForumTopic" lazy="true" inverse="true"
cascade="*all-*delete-orphan">
     <key column="ForumId" on-delete="cascade" />
     <one-to-many class ="ForumTopic"/>
</bag>


Cascade="delete-orphan" has a different meaning, it means that a topic is
deleted when you remove the topic from the forum; like
forum.RemoveTopic(topic).

You can get more info here:
http://ayende.com/Blog/archive/2006/12/02/nhibernatecascadesthedifferentbetweenallalldeleteorphansandsaveupdate.aspx


2011/1/12 ZNS <[email protected]>

>
> Thank you for the reply. Yes, I didn't expect a casade to actually
> happen in the db because it wasn't set up yet. Well, not by me...
>
> On 12 Jan, 19:51, José F. Romaniello <[email protected]> wrote:
> > And what is wrong? on-delete="cascade" means that the childs are deleted
> > automatically in the database with a trigger, so its only required one
> > command, one roundtrip.
> >
> > 2011/1/12 ZNS <[email protected]>
> >
> > > 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.
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
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.

Reply via email to