-->
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: getObject with LockMode.UPGRADE getting stale data?
PostPosted: Fri Jan 12, 2007 5:05 pm 
Newbie

Joined: Fri Jan 12, 2007 4:55 pm
Posts: 3
I am having an issue using LockMode.UPGRADE.

My code looks like;

MyObject a = getObject(criteria, LockMode.UPGRADE);
a.incrementCount();
commitTransaction();

What appears to be happening is that several machines/threads try to access the object at once. Thread1 gets the lock. It increments the count from 1 to 2 and commits. Then the second thread gets the lock, but its copy of the object still has count 1. So after it increments the count is still 2, but I want it to be 3. Is thread2 getting the object from a cache? I thought with LockMode.UPGRADE hibernate would bypass the cache?

What am I missing/misunderstanding and what is the correct fix - should I call refresh right after the call to getObject?

TIA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 4:00 pm 
Newbie

Joined: Thu Mar 23, 2006 10:52 am
Posts: 4
In case you're still trying to solve this problem: what's going on in that getObject method? It's hard to tell what's happening, without it.


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.