Thanks Alex,

>From what I could see Fluent Nhibernate doesn't support idBags, I could
switch to hmb mappings for this specific case. But I would like to know, if
what I did is suposed to work, maybe I just misunderstood something.

Thanks for any comments!

On Sat, Apr 2, 2011 at 8:49 AM, H.Alex <[email protected]> wrote:

> Off the top of my head .. maybe you could try using an idbag and see
> if that helps..
>
> On Apr 2, 12:52 am, Dzyann Leleur <[email protected]> wrote:
> > Thank you very much Roger,
> > I was looking for something like that but I couldn't find it.
> >
> > I have implemented what the link says, but is not working properly, in
> some
> > cases doesn't delete at all and in others it just keeps deleting item by
> > item.
> >
> > I am using Fluent Nhibernate for mapping, but here is the mapping that it
> is
> > producing for the class Query:
> >
> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> > default-access="property" auto-import="true" default-cascade="none"
> > default-lazy="true">
> >   <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Query,
> > Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
> > table="`Query`">
> >     <id name="Id" type="System.Int32, mscorlib, Version=4.0.0.0,
> > Culture=neutral, PublicKeyToken=b77a5c561934e089">
> >       <column name="Id" />
> >       <generator class="identity" />
> >     </id>
> >     <bag cascade="all-delete-orphan" inverse="true" name="NasLocations"
> > mutable="true">
> >       <key>
> >         <column name="Query_id" />
> >       </key>
> >       <one-to-many class="NASLocation, Domain, Version=1.0.0.0,
> > Culture=neutral, PublicKeyToken=null" />
> >     </bag>
> >     <bag cascade="all-delete-orphan" inverse="true" name="MetadataItems"
> > mutable="true">
> >       <key>
> >         <column name="Query_id" />
> >       </key>
> >       <one-to-many class="MetadataItem, Domain, Version=1.0.0.0,
> > Culture=neutral, PublicKeyToken=null" />
> >     </bag>
> >
> > Mapping for QueryMetadataItem and NasLocations relation with Query:
> >
> > <many-to-one class="Query,Domain, Version=1.0.0.0, Culture=neutral,
> > PublicKeyToken=null" foreign-key="Query_id" name="Query">
> >       <column name="Query_id" />
> >     </many-to-one>
> >
> > I am deleting the items as follows:
> > query.NasLocations.Clear();
> > query.MetadataItems.Clear();
> >
> > And then removing the Query itself.
> > The NasLocations items do not get deleted at all, and the MetadataItems
> get
> > delete one by one.
> >
> > Any ideas?
> >
> > Dzy.-
> >
> > PS: On the mappings I deleted most of the namespaces text, to make the
> > mapping smaller.
> >
> > On Fri, Apr 1, 2011 at 6:42 PM, Roger Kratz <[email protected]
> >wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > >http://www.nhforge.org/doc/nh/en/index.html#performance-collections-o.
> ..
> >
> > > -----Original Message-----
> > > From: [email protected] [mailto:[email protected]] On
> Behalf
> > > Of Dzyann
> > > Sent: den 1 april 2011 23:23
> > > To: nhusers
> > > Subject: [nhusers] Delete Cascade taking a long time
> >
> > > Hi,
> >
> > > I have a an entity Query that has a lot of items Metadata in a relation
> > > "one-to-many".
> > > When I delete the Query, I want all its childs to be delete too, so I
> set
> > > cascade to all-delete-orphan.
> >
> > > The items get deleted, but it takes a lot of time. The query can have
> many
> > > items, lets say 95k items.
> > > I checked out with the SQL Profiler to see what was going on, and I saw
> > > that each Metadata Item is getting deleted one by one like:
> >
> > > exec sp_executesql N'DELETE FROM MyDatabase.dbo.[QueryMetadata] WHERE
> Id =
> > > @p0',N'@p0 int',@p0=302401
> >
> > > This takes time, and produces a bad user experience. I would like to
> hear
> > > out any recommendations.
> > > Maybe is better if I delete the items with a sql sentence?
> >
> > > Thanks in advance for your help!
> >
> > > Dzy.-
> >
> > > --
> > > 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.
>
> --
> 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