Class SelectedFieldsLockingPolicy
- java.lang.Object
-
- org.eclipse.persistence.descriptors.FieldsLockingPolicy
-
- org.eclipse.persistence.descriptors.SelectedFieldsLockingPolicy
-
- All Implemented Interfaces:
Serializable
,Cloneable
,org.eclipse.persistence.internal.descriptors.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 Summary
Constructors Constructor Description SelectedFieldsLockingPolicy()
PUBLIC: Create a new selected fields locking policy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLockFieldName(String fieldName)
PUBLIC: Add a field name to lock on.void
addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
INTERNAL: Values to be included in the locking mechanism are added to the translation row.List<org.eclipse.persistence.internal.helper.DatabaseField>
getLockFields()
INTERNAL: Returns the lock fieldsvoid
initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: It is responsible for initializing the policy;void
setLockFieldNames(List<String> lockFieldNames)
PUBLIC: Set the field names to lock on.-
Methods inherited from class org.eclipse.persistence.descriptors.FieldsLockingPolicy
addLockFieldsToUpdateRow, buildDeleteExpression, buildUpdateExpression, clone, compareWriteLockValues, getBaseValue, getLockOnChangeMode, getValueToPutInCache, getVersionDifference, getWriteLockField, getWriteLockUpdateExpression, getWriteLockValue, initializeProperties, isCascaded, isNewerVersion, isNewerVersion, isStoredInCache, mergeIntoParentCache, mergeIntoParentCache, setDescriptor, setLockOnChangeMode, setupWriteFieldsForInsert, shouldUpdateVersionOnMappingChange, shouldUpdateVersionOnOwnedMappingChange, supportsWriteLockValuesComparison, updateRowAndObjectForUpdate, validateDelete, validateUpdate
-
-
-
-
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.
-
addLockValuesToTranslationRow
public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query) throws DatabaseException
INTERNAL: Values to be included in the locking mechanism are added to the translation row. For changed fields the normal build row is ok as only changed fields matter.- Specified by:
addLockValuesToTranslationRow
in interfaceorg.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
- Specified by:
addLockValuesToTranslationRow
in classFieldsLockingPolicy
- Throws:
DatabaseException
-
getLockFields
public List<org.eclipse.persistence.internal.helper.DatabaseField> getLockFields()
INTERNAL: Returns the lock fields
-
initialize
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: It is responsible for initializing the policy;- Specified by:
initialize
in interfaceorg.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
- Overrides:
initialize
in classFieldsLockingPolicy
-
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.
-
-