3
votes

I've got the entity that contains @version field. Sometimes I need to update it in spite of optimistic locking exception.

Can I turn it off somehow in that case? Or I should just reload entity and retry to save it n times until it updates?

1

1 Answers

0
votes

You can work directly agains the connection:

org.hibernate.Session.doWork(Work work).

But you are incurring in last write wins. It is better to use transactions isolation levels to perform row lock. But the database must support them.

Hibernate 3.x has the Session.connection() but in 4 it is gone.