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.
|