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