-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Object retrieve from ASP Session and SaveorUpdate
PostPosted: Wed Nov 29, 2006 8:30 am 
Newbie

Joined: Wed Nov 29, 2006 7:46 am
Posts: 9
Hello,

I have a "small" question about how nhibernate works. Im programming an ASP form with a parent-child persistent class. Then parent class have IList associate to a bag in the xml mapping and define with cascade="all-delete-orphan" parameter.

In the form i show the parent details and a gridview with the IList elements, the user can modify the fields in the gridview. The user have the option to cancel the modifications, and for it, i create a temporary object and save the changes in the parent´s childlist. I save this object in the asp session until the user press the button cancel or update. If cancel the form reload the object and if press save execute SaveorUpdate(tempobject).

And now my question:

It works!!, nhibernate save/update or delete the columns but the problem is this: first of all it always execute an update for the parent object and all of the childrens independently of that the children is modified or not and then insert/update/delete the childrens.

I test it without store the tempobject in asp session and it works perfectly.

I use the NHibernate Best Practices system to manage nhibernate sessions and i think the problem is when i try to save a object with a session diferent than i retrieve from the BD, nhibernate think that all lines are changed.My question is only to confirm this, and if anyone have other idea to do it.

Thanks for all (and sorry for my english xD)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 11:30 am 
Newbie

Joined: Wed Nov 29, 2006 7:46 am
Posts: 9
Other important problem, if the child collection is lazy and not yet loaded the program fail and not save nothing, a problem in the serialization i supose.

I continue work but im starting to think that this is not the best way to do it.

Maybe tempobject can be only the ilist of childs not the full parent object.

Post later more results :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 3:12 pm 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
If you Update the object in a different session then NH does not know what has changed and delete and re-add all your children. If you are sure nothing has changed, you can try Session.Lock() on your parent with LockMode.None and that may prevent the extra queries.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 5:37 am 
Newbie

Joined: Wed Nov 29, 2006 7:46 am
Posts: 9
Thanks grennis .
I test Session.Lock() because i dont know how it works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.