We are using Hibernate 3.6.0. We have requirement of retrieve next available record from the table. How do we control retrieving same record by multiple concurrent users. We need to read the next available record and update the status on column (kind of lock) to avoid next user retrieving the same record. We added Version column on the table (Optimistic lock), but it seems controlling on update.
What is the best solution in Hibernate to achieve this?
Thanks in advance. Venkat
Have you tried locking the record in question? Hibernate supports pessimistic locking (SELECT FOR UPDATE
), look at the documentation.
You might also try optimistic locking, it kind of depends on the level of concurrency you expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With