-->
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: Locking with joined subclasses
PostPosted: Wed Jul 28, 2010 4:28 am 
Newbie

Joined: Wed Jul 28, 2010 3:23 am
Posts: 1
Hello,

we use hibernate, oracle and pessimstic locking, to avoid concurrent modification through different threads.
This worked fine for a while. But now we sometimes get deadlocks. We analyzied and found the cause.

Our mapping:
Code:
<class name="TraceObject" table="TraceObjects">
      <cache usage="read-write" />
      <id name="objectId" column="objectId" type="long">
         <generator class="native">
            <param name="sequence">TraceObjectsSeq</param>
         </generator>
      </id>
      <timestamp name="dbVersionControl" />
      ...
</class>

<joined-subclass name="VehicleObject" table="VehicleObjects" extends="TraceObject">
   <key column="id" />
   ...
</joined-subclass>


In thread A we retrieve the vehicleObject through Criteria:
Code:
criteria.setLockMode(LockMode.UPGRADE);
criteria.uniqueResult();

This results in a select statement with FOR UPDATE OF TraceObjects.objectId. This only locks the relevant data in table TraceObjects.



In thread B we retrieve the vehicleObject through Session:
Code:
getSession().get(getPersistentClass(), ao_Id, LockMode.UPGRADE);

This results in a select statement with FOR UPDATE. This locks the relevant data in table TraceObjects and joined table VehicleObjects.

We think, our problem are the different deepnesses of the locks.

Is there a way to create locks on criterias just with "FOR UPDATE" not with "FOR UPDATE OF"? Does anybody know, why the locking from session and from criteria works different?


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.