-->
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: No Exception for optimistic lock condition?
PostPosted: Tue Aug 07, 2007 6:51 pm 
Newbie

Joined: Sat Aug 04, 2007 10:46 am
Posts: 8
NHibernate 1.2

Hi,
I have optimistic locking set on a class also with a version timestamp.

Code:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="FusionPlugin.Model.ConversationNode, FusionPlugin" lazy="false" table="fusion_quests_conv"  optimistic-lock="version">
      <id name="Guid" type="string"  unsaved-value="null">
         <column name="guid" sql-type="varchar(64)" not-null="true" />
         <generator class="Fusion.FusionIDGenerator, SubFusion" />
      </id>
      <!--<timestamp name="version" generated="never" access="field" column="version"/>-->
      <version name="version" access="field" column="version" type="timestamp" generated="never"/>

      <many-to-one class="FusionPlugin.Model.Quest, FusionPlugin" name="Quest" column="quest" not-null="true"/>      
   </class>
</hibernate-mapping>


The version generates fine now, however something strange occurs. I serialize the object to disk between application starts and when I de-serialize it, I session.Update(po,po.guid) the object with some new state. Works fine. Now, if I manually alter the version timestamp in the database for that object, I expect my next object update to cause a lock collision.

Well, sorta. It correctly does not overwrite the database state with the new object state (because the versions do not match), but it also does not throw an exception to notify my application of a stale state for this object. Rather, session.Update(po,po.guid) just returns gracefully.

I can reproduce this at will.

Any clues?

thanks,
Sessh


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 3:58 am 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
Just because you call update doesn't mean that the information is flushed to the database - database updates are cached for performance reasons. You should read up on ISession.Flush and how automatic flushing can be configured.

Cheers,

Symon.


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.