-->
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.  [ 2 posts ] 
Author Message
 Post subject: Dynamic Update doesn't work on evicting object from Session
PostPosted: Tue Apr 07, 2009 7:16 am 
Newbie

Joined: Tue Apr 07, 2009 7:05 am
Posts: 3
Hibernate version:
3.2.4

Mapping documents:
<class table="LPN" name="com.xxx.lpn.LPN" dynamic-insert="true" dynamic-update="true">

<id type="java.lang.Long" column="LPN_ID" access="property" name="lpnId">
<generator class="sequence">
<param name="sequence">LPN_ID_SEQ</param>
</generator>
</id>
<version type="java.lang.Long" column="VERSION" access="field" name="hibernateVersion"/>

......
</class>


Here is the flow:
<b>Scenario 1 : </b>
1. Initiate transaction using TransactionTemplate/or Spring Proxy or EJB.
2. Load the LPN object
3. Evict the object from session
4. Update the LPN object with different values.

In above case the dynamic udpate doesn't work and hibernate sql shows that it's updating all the columns. If we skip the #3 then dynamic update is working. Does any one know the reason behind it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 07, 2009 7:47 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
To generate dynamic update statement (when you use dynamic-update=true), Hibernate need to know what properties has changed. Hibernate do this by comparing the object state with the state in persistence context (that is associated with session). so if you evict the object from session (means from the persistence context), hibernate can't find out what properties have change and then by default it will have all the properties in update statement.

please modify as mention below and try. I hope it will help you to generate the dynamic update statement.

Code:
<class table="LPN" name="com.xxx.lpn.LPN" dynamic-insert="true" dynamic-update="true" select-before-update="true">


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