Class PessimisticLockingPolicy

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class PessimisticLockingPolicy
    extends Object
    implements Cloneable, Serializable

    Description: This policy is used to configure bean level pessimistic locking feature. It is set on the CMPPolicy instance of the ClassDescriptor Note that bean is not pessimistic locked in the following scenarios:

    • No presence of a JTA transaction
    • The current transaction is created and started by the Container for the invoking entity bean's method only. (i.e. invoke a business method without a client transaction)
    • The bean has already been pessimistic locked in the current transaction
    • Execution of ejbSelect
    • Traversing relationship does not lock the returned result.


    • Configure locking modes of WAIT or NO_WAIT
    • Provide utility to configure an ObjectLevelReadQuery with pessimistic locking based on this policy.
    See Also:
    CMPPolicy, Serialized Form
    TopLink 10.1.3
    • Field Detail

      • lockingMode

        protected short lockingMode
    • Constructor Detail

      • PessimisticLockingPolicy

        public PessimisticLockingPolicy()
    • Method Detail

      • getLockingMode

        public short getLockingMode()
        PUBLIC: Return locking mode. Default locking mode is ObjectLevelReadQuery.LOCK.
        short locking mode value of ObjectLevelReadQuery.LOCK or ObjectLevelReadQuery.LOCK_NOWAIT
      • setLockingMode

        public void setLockingMode​(short mode)
        PUBLIC: Set locking mode. If the mode is not a valid value, the locking mode is unchanged.
        mode - must be value of ObjectLevelReadQuery.LOCK or ObjectLevelReadQuery.LOCK_NOWAIT
      • clone

        public Object clone()
        INTERNAL: Clone the policy
        clone in class Object