This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!

Radhika Bhagavathula

Greenhorn
+ Follow
since Feb 11, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Radhika Bhagavathula

Just and 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.
Hi Mark, Peer

I have been using a similar scenario for my application where I am using transactions + concurrency control. 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.