Hi,
The Domain, is designed as it is, is a very specific case, that doesn't
happen much. And actually, is just an applicatin to migrate data, so the
user doesn't have this problem of having such massive associations.
I am not going to perform operations like you put, for each item of the
collection, we are just doing queries over them.
What I want to know if the way I set the deletion was correct.
This is what i have (without the on-delete="cascade")
<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.
I did this following the link Roger gave me. I don't see what I am doing
wrong.
Regards,
Dzy.-
On Mon, Apr 4, 2011 at 2:48 PM, Fabio Maulo <[email protected]> wrote:
> public class Country
> {
> ...
> ...
> public IEnumerable<Person> People{get; private set;}
> }
>
> using(var session = sf.OpenSession())
> {
> var china = s.QueryOver<Country>().Where(x=> x.Name ==
> "China").SingleOrDefault();
> foreach(var person in china.People)
> {
> DoSomethingButComeBackTomorrowToSeeResult();
> }
> }
>
> The link that Roger gave you is correct what is incorrect is the design of
> the domain.
>
> On Mon, Apr 4, 2011 at 2:33 PM, Dzyann Leleur <[email protected]> wrote:
>
>> Hi Fabio,
>> What do you mean with that trying to map a collection that big is wrong?
>> Do you mean like I shouldn't use NHibernate? Or that the collection
>> shouldn't be that big?
>> The collection is being created by a service, we don't have a choice but
>> having that collection, there is no other way. The service is not working
>> with Nhibernate to create the data. We are using Nhibernate for the User
>> interface part, that creates queries on the data. But has the option to
>> delete them too.
>>
>> When I saw how Nhibernate was behaving, I thought that maybe I shouldnt
>> try to delete the collection with Nhibernate and just do it with SQL, but I
>> wanted to see different options.
>> I am going to try the "on-delete="cascade"", but, was the approach I
>> implemented following the link:
>>
>> http://www.nhforge.org/doc/nh/en/index.html#performance-collections-oneshotdelete
>> that Roger gave me, wrong?
>>
>> Regards,
>>
>> Dzy.-
>>
>> On Sun, Apr 3, 2011 at 10:04 PM, Fabio Maulo <[email protected]>wrote:
>>
>>> try to map a collection with 95K items is simple wrong and nothing more.
>>> btw you can use on-delete="cascade"
>>>
>>>
>>> On Fri, Apr 1, 2011 at 6:23 PM, Dzyann <[email protected]> wrote:
>>>
>>>> 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.
>>>>
>>>>
>>>
>>>
>>> --
>>> Fabio Maulo
>>>
>>> --
>>> 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.
>>
>
>
>
> --
> Fabio Maulo
>
> --
> 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.