Application Module – Optimistic Lock vs Pessimistic Lock

In Application Module the locking is by default pessimistic lock.

jbo.locking.mode is pessimistic by default.

But the practice should be optimistic locking.

How to change the locking mode.

We can easily change the locking mode by opening
“EDIT BUSINESS COMPONENT CONFIGURATION”.

 

change the value to optimistic.

The pessimistic locking holds lock on database but optimistic does not hold lock on database.

So in case concurrent update

1> pessimistic locking – The second user for concurrent data update will stuck with error until first user saves or undo data change.
The second user will be forced to wait until first user will Save or Undo his changes in order to proceed with data commit. Another option for the second user – Undo his change in the current row and proceed with other rows editing. When the first user will close his transaction, the second one will be able to save his changes for previously locked record as well.

2> optimistic locking – The first user will not hold database lock and second user will be able to continue his work. At the same time, first user will be able to press Save button second time, and his data will be committed.

So for general optimistic locking is better to use.

By the way

There are three types of locking:
1. normal
2.optimistic
3.pessimistic