Have you modified something in the aggregate before the delete? If not...

Using(tran)
Using(newSession)
 newSession.Lock(prevUnchangedLoadedRoot, LockMode.x) <--reassociate uncomplete 
graph
 session.CreateQuery(reloadObjectWithNecessaryChildren)  <--fill with necessary 
child objects
 session.Delete(prevUnchangedLoadedRoot)



-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Paladin_za
Sent: den 12 november 2008 12:15
To: nhusers
Subject: [nhusers] Re: Optimisation Question


Ok, maybe you guys are underestimating the fact that it's a "complex"
object model.

For example I have a root object with a bunch of children. The problem
is that at various levels (depth) in the structure I have
relationships across the structure to other levels (depth). You can't
just delete a root object as it does not make sense for the root
object to know about a leaf object (directly) within the structure.

That is why Nhibernate needs to go and select the children to find the
leaf objects to be able to delete them.

I still think I'd like to be able to tell nhibernate to (in those
cases instead of enumerating all the various levels of child lists,
doing single selects at a time) query the whole object graph for the
entity in question in one shot.

I'm just not sure how I would go about doing this...

On Nov 12, 10:53 am, Roger Kratz <[EMAIL PROTECTED]> wrote:
> You can't let the db do the work for 
> you?http://www.hibernate.org/hib_docs/reference/en/html/mapping.html
> 5.1.21 - on-delete="cascade"
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
> Paladin_za
> Sent: den 12 november 2008 06:34
> To: nhusers
> Subject: [nhusers] Optimisation Question
>
> Hi All
>
> I need to optimize a process that potentially needs to delete
> instances consisting of a deep and complex object graph.
>
> My first solution was to greedy load the whole complex object graph
> and then delete the instances that needed to be deleted.
> The problem with this method is that loading the complete object graph
> takes too long (its complex with a lot of data)
> I don't always need to delete objects.
>
> My second solution is to load only what I need at startup and then
> when an instance needs to be deleted the ORM lazily loads the needed
> child data necessary to perform the delete.
> This will run slower, but only in the cases when a delete is required
> (which is rare).
>
> A third solution would be to find all the objects that need to be
> deleted and then greedily load only their info. My problem is I don't
> know how to approach this. At the moment I use the session to retrieve
> my base instance. Can I just do a query on the session and NHibernate
> will "magically" attach the child objects to my existing instance?
>
> Any ideas.
>
> Thanks



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