-->
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.  [ 5 posts ] 
Author Message
 Post subject: Dynamic Updates Across Sessions.
PostPosted: Wed Feb 15, 2006 2:15 am 
Beginner
Beginner

Joined: Mon Jan 09, 2006 8:02 am
Posts: 22
Hi,

I am currenntly using NHibernate 1.0.1. I need some help regarding Dynamic Updates. I have the following senario.

1. I Retrive an Object using Load and get in one Session.
2. I update only a few Cols of the same Object but in a different session .

Now when i call Update i want Dynamic Update to work. Any Ideas how can i achieve the Same??. That is i want to fire a update querry only against those attributes that have Changed. I guess this should be possible if i use the Second Level Cache. Any Ideas on the same.



If this is Not Possible ios it in NHIbernates RoadMap.


Regards

Prasanth


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 7:26 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
No, it's not possible in NH. For dynamic update to work the object must be modified and updated in the same session. There are no plans to make dynamic updates work with separate sessions.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 4:08 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
What happens then, if you have classes marked as dymamic-update, and the scenario described above occurs? I assume it will just update all columns, since it doesn't know which ones changed? From what I understand, that will frequently be the scenario for us ...

I thought dynamic-update figured out what columns actually changed by re-selecting the (old) state of the object. Doesn't it need to select the row anyway to do optimistic lock checking (i.e. select the row's version number)? If it figured out what changed this way, rather than by the original copy of the object internally saved by the session that loaded it, it shouldn't matter if the object is loaded in one session and saved in another.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 9:02 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, you can tell it to re-select the object by using select-before-update="true" - I forgot about it. No, it doesn't need to select the row anyway to check the version, because the version may be checked by the update statement itself. But select-before-update is usually less efficient than just plain update, unless you have some expensive triggers attached to the table.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 11:16 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Yes, we have expensive triggers that act upon the changed columns, so we don't want any columns being updated to the same value. We are setting select-before-update, so we should be OK. We usually don't do volume inserts/updates, so we're not too concerned about update performance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.