-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with Hibernate transactions
PostPosted: Fri Feb 11, 2011 5:41 pm 
Newbie

Joined: Fri Feb 11, 2011 5:35 pm
Posts: 5
Hi

I have been using transactions + concurrency control in my application. I tried using optimistic and pessimistic locking but it does not seem to work
I am using Spring and Hibernate 3.2.5.
My application scenario is :
1) user can select multiple number of files from the UI
2) for each file a NEW transaction is run consisting of SELECT and UPDATE

However, if I select 2 files for example, for processing, instead of:

SELECT
UPDATE
SELECT
UPDATE

the order of execution shows

SELECT
SELECT
UPDATE
UPDATE

the second transaction starts even before the first transaction finishes and reads the not yet updated values (dirty read).
I tried pessimistic locking with Query.setLockMode which does not seem to work with DB2 which is the database I am using. I also tried to set the hibernate.transaction.isolation values and also on the Spring side with isolation attribute for @Transactional annotation.

Can somebody please help me where am I going wrong/what additional needs to be done so that the second transaction starts only after the first finishes. Appreciate your help.


Top
 Profile  
 
 Post subject: Re: Problem with Hibernate transactions
PostPosted: Fri Feb 11, 2011 6:01 pm 
Newbie

Joined: Fri Feb 11, 2011 5:35 pm
Posts: 5
Just an update from my side. Because none of the locking methods worked, I used synchronized for the Spring method which already was annotated @Transactional and it worked.
Now the order of execution is :

SELECT
UPDATE
SELECT
UPDATE
AND SO ON...

is this the correct approach? is there an alternative to using synchronized as this might be overhead for performance? Appreciate your suggestions


Top
 Profile  
 
 Post subject: Re: Problem with Hibernate transactions
PostPosted: Fri Feb 11, 2011 7:32 pm 
Newbie

Joined: Wed Jan 26, 2011 12:32 pm
Posts: 12
Did you configured hibernate to use JTATRANSACTIONFACTORY instead of JDBC?


Top
 Profile  
 
 Post subject: Re: Problem with Hibernate transactions
PostPosted: Sat Feb 12, 2011 5:11 pm 
Newbie

Joined: Fri Feb 11, 2011 5:35 pm
Posts: 5
I am using JDBC with hibernate..


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