Skip Headers

# Optimistic Locking and Rollbacks

Previous

Next

With optimistic locking, use the `UnitOfWork` method `commitAndResumeOnFailure` (see "Resuming a Unit of Work After Commit") to rollback a locked object's value, if you store the optimistic lock versions in the cache.

If you store the locked versions in an object, you must refresh the objects (or their versions) on a failure. Alternatively, you can acquire a new unit of work on the failure and reapply any changes into the new unit of work.