How are you configuring the other side of the relationship?

On Sat, Jul 30, 2011 at 1:12 PM, A. <[email protected]> wrote:

> I have simple Parent-Child relationship, Parent has many Child
> objects, the relation is bidirectional:
>
> public class Parent
> {
>    public virtual int Id { get; protected set; }
>    public virtual string Name { get; set; }
>    public virtual IList<Child> Children { get; set; }
> }
>
> public class Child
> {
>    public virtual int Id { get; protected set; }
>    public virtual string Name { get; set; }
>    public virtual Parent Parent { get; set; }
> }
>
> Mapping for the relation sets cascade to AllDeleteOrphan to remove
> Child objects not referenced by Parent any more and sets that relation
> is inverse, to enable one-shot deletes as explained here:
>
> http://www.nhforge.org/doc/nh/en/index.html#performance-collections-oneshotdelete
>
> HasMany(x => x.Children).Cascade.AllDeleteOrphan().Inverse();
>
> And now I'm clearing the list of Child objects:
>
> var parent = session.Get<Parent>(1);
> parent.Children.Clear();
> session.Update(parent);
>
> NHibernate deletes the Child object as expected, but it do this by
> sending separate DELETE query for each Child from the collection:
> DELETE FROM Child WHERE Id = ... - that can mean really LOT of
> queries.
>
> According to the docs mentioned, it should issue one DELETE using
> foreign key, but it doesn't - I have multiple DELETEs by Child ID. Am
> I missing something?
>
> (NH 3.2.0)
>
> --
> 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.
>
>

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