-->
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: org.hibernate.exception.LockAcquisitionException
PostPosted: Tue Oct 25, 2011 10:18 pm 
Newbie

Joined: Sat Jan 27, 2007 4:46 pm
Posts: 2
Location: BANGALORE INDIA
Hi All,

I am facing a issue with Transaction management during multi-threading on db layer.

Application is built using spring for integration and hibernate for persistance (3.X). Transactions are handled by Container. Requests are served by MDB(2.1).

Object relations are as follows
Configurations is one object and different products can be created based on this configurations

Configurations --> one to many relation with Products

Application works fine with single thread, during multi threading, the persistance layer fails with deadlock issue even for two concurrent messages.

From logs could find that if one thread is working updating persistance layer and if another thread too starts updating another set of record (both messages are unique), dead lock occurs. Ideally lock on a table during update is row level, but seems like it is locking entire table (may be even due to parent child relations).

If the other thread starts after previous thread completes it works.

Errors :-
org.springframework.dao.CannotAcquireLockException: could not update: [com.xx.Products#10180873]; SQL [update Products set Prod_ID=?... where PROD_TID=?]; nested exception is org.hibernate.exception.LockAcquisitionException: could not update: [com.xx.Products#10180873]
Caused by: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource

Hibernate confirgurations
<prop key="hibernate.order_inserts">true</prop>
<prop key="hibernate.order_updates">true</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.batch_size>0</prop>

Kindly let me know your comments on above errors
Thanks

_________________
Believe In Your Self,


Top
 Profile  
 
 Post subject: Re: org.hibernate.exception.LockAcquisitionException
PostPosted: Mon Oct 31, 2011 10:39 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I had a very similar problem and I resolved it by avoiding any unnecessary calls of flush (implicit and explicit).
In this way the Locks are just hold during the commit itself, so the risk of such concurrency is much smaller.


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.