ChangingTheLockingPolicy

Changing the locking policy

 

CMP locking is described here.

 

Common mistakes

 

Trying to use a globally shared instance cache without a real lock

 

If you DON'T use a real BeanLock implementation like QueuedPessimisticEJBLock then you cannot

use the global shared instance cache. You need to use the "instance per transaction"

configuration which will give you commit option C semantics and potentially "MVCC" when used

with optimistic locking.

 

Using CMP outside a transaction with a shared cache

 

Since locks are taken per instance at the transaction level, if you use CMP outside a transaction

then the locking is undefined (see also the warning paragraph in the spec about using CMP

outside a transaction).

 

Basically, if you are doing anything more than read-only semantics you are probably not going to

get the behaviour you expect.