I use Hibernate version 4. We have a problem in batch process. Our system works as below
- Select set of records which are in 'PENDING' state
- Update immediately to 'IN PROGRESS' state
- Process it and update to 'COMPLETED' state
The problem when we have two servers and executing at same time, we fear of having concurrency issue. So we would like to implement DB Lock for first two steps. We used query.setLockOptions()
, but it seems not working. Is there any other to have table level lock or Row level lock till it completes select and update. Both are in same session.
We have options in JDBC that LOCK TABLE <TABLE_NAME> WRITE
. But how do we implement in hibernate or is it possible to implement select..for update in hibernate?