-->
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.  [ 6 posts ] 
Author Message
 Post subject: need help: session cannotacquirelock exception
PostPosted: Thu Feb 12, 2009 4:45 am 
Newbie

Joined: Thu Feb 12, 2009 4:32 am
Posts: 2
I'm using spring, hibernate 3.1 and mysql 5.1.

I'm working with some legacy code that does some pretty bad coding. Here is what's happening:

This uses open session in view filter from Spring.

handleRequest() {

// This is marked transactional propagation_required using spring AOP
manager.updateObject(objA);

objA.setAddress(...);

// This is the stupid part
use remote call to invoke another thread to do some processing on objA.
blocks until the remote call finishes
}

so that other thread loads objA, writes to it, and I got a cannotacquirelockexception.

So my question is: does the hibernate session in my original call actually hold a lock to objA so that my second transaction cannot acquire the lock? I can't find anything about this in the docs or on google, and I don't understand how the session can hold a lock if it's not in a transaction.

If it is actually holding a lock on objA, how would I be able to release it? Do I do a session.flush() right before i do the remote call?

Please help. I'm a hibernate noob and this is making me very confused. Thanks so much.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 5:13 am 
Beginner
Beginner

Joined: Sat Jan 26, 2008 6:33 am
Posts: 24
It's just a wild guess, but I would try to flush the session like you suggested it yourselfe.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 6:16 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
If flush does not work then may be you can try a session.evict(objA)

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 2:08 am 
Newbie

Joined: Thu Feb 12, 2009 4:32 am
Posts: 2
I tried both flush and evict, neither works.

Does hibernate actually hold locks to database objects outside of a database transaction?

littypreethkr wrote:
If flush does not work then may be you can try a session.evict(objA)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 4:23 am 
Beginner
Beginner

Joined: Sat Jan 26, 2008 6:33 am
Posts: 24
Are you sure were talking about a db lock here and not some threading lock? Because im out of ideas. At least with the available code here.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 4:36 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Yes I think you should probably post the code and atleast the stack trace

_________________
Regards,
Litty Preeth


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.