Class SelectedFieldsLockingPolicy

  • All Implemented Interfaces:
    Serializable, Cloneable, OptimisticLockingPolicy

    public class SelectedFieldsLockingPolicy
    extends FieldsLockingPolicy

    Purpose: An implementation of the OptimisticLockingPolicy interface. This policy compares selected fields in the WHERE clause when doing an update or a delete. If any field has been changed, an optimistic locking exception will be thrown. Note that the fields specified must be mapped and not be primary keys.

    NOTE: This policy can only be used inside a unit of work.

    Since:
    TopLink 2.5
    See Also:
    Serialized Form
    • Constructor Detail

      • SelectedFieldsLockingPolicy

        public SelectedFieldsLockingPolicy()
        PUBLIC: Create a new selected fields locking policy. A field locking policy is based on locking on the specified fields by comparing with their previous values to detect field-level collisions. Note: the unit of work must be used for all updates when using field locking.
    • Method Detail

      • addLockFieldName

        public void addLockFieldName​(String fieldName)
        PUBLIC: Add a field name to lock on. All fields in this list will be compared when updating if the value of any of the fields does not match the value in memory, an OptimisticLockException will be thrown. Note: An Automatic update will not be done on this field, only a comparison occurs.
      • getLockFields

        public List<DatabaseField> getLockFields()
        INTERNAL: Returns the lock fields
      • setLockFieldNames

        public void setLockFieldNames​(List<String> lockFieldNames)
        PUBLIC: Set the field names to lock on. All fields in this list will be compared when Updating. If the value of any of the fields does not match the value in memory, an OptimisticLockException will be thrown. Note: An Automatic update will not be done on this field, only a comparison occurs.
      • setLockFields

        protected void setLockFields​(List<DatabaseField> lockFields)
        INTERNAL: Sets the lock fields
      • setLockFieldsByTable

        protected void setLockFieldsByTable​(Map<DatabaseTable,​List<DatabaseField>> lockFieldsByTable)
        INTERNAL: Used to set the field names to be used in this policy.