-->
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.  [ 1 post ] 
Author Message
 Post subject: Help on disable optimistic locking at component field level
PostPosted: Thu Jan 22, 2015 8:36 pm 
Newbie

Joined: Thu Jan 22, 2015 8:15 pm
Posts: 1
Hi,
I am trying to turn off optimistic locking for a particular field within a component. Turning off at the component level (which applies for all fields in component) works. But not for a particular field with in the component. I am using hibernate 3.2.x

Let me explain more about the problem

Member.hbm.xml

<class name="com.test.core.model.member.Member" abstract="true"
table="MEMBER" optimistic-lock="dirty" dynamic-update="true"
polymorphism="explicit" discriminator-value="LITE">

.....
.....
<component name="helper" class="com.test.core.model.Helper">
<property name="status">

<column name="STATUS" />
<type name="org.hibernate.type.EnumType">
<param name="enumClass">
com.test.core.model.Helper$Status
</param>
</type>
</property>
<property name="changeXML" type="string">
<column name="CHANGE_XML" />
</property>
<property name="lastChange" type="timestamp">
<column name="LAST_CHANGE" />
</property>
</component>
</class>
</hibernate-mapping>

I am constrained to use optimistic-lock="dirty" at the class level, so I cannot switch to "version".
However would like to disable optimistic checks by hibernate for changeXML field inside the component.

So I changed
<property name="changeXML" type="string" >
to
<property name="changeXML" type="string" optimistic-lock="false">

Because this is with in a component this setting is not respected for some reason. As a result hibernate internally generates the verification query before committing an update to changeXML.
ie update MEMBER SET CHANGE_XML ="NEWVALUE" WHERE ID=SOMETHING AND CHANGE_XML=OLDVALUE

However changing at the component level ie
changing from
<component name="helper" class="com.test.core.model.Helper">
to
<component name="helper" class="com.test.core.model.Helper" optimistic-lock="false">
works by respecting this setting and hibernate doesnt generate the update statment

We cannot settle with that option of changing at component level because concurrent updates to "status" is expected and will not fail with staleobjectstateexception.

Is there a way to tell hibernate to respect the optimistic-lock="false" setting within a component ?

Thanks for taking time to read..


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

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.