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.
Modifier and Type | Field and Description |
---|---|
protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> |
lockFields |
protected java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>> |
lockFieldsByTable |
allNonPrimaryKeyFields, descriptor
Constructor and Description |
---|
SelectedFieldsLockingPolicy()
PUBLIC: Create a new selected fields locking policy.
|
Modifier and Type | Method and Description |
---|---|
void |
addLockFieldName(java.lang.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.
|
protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> |
getFieldsToCompare(org.eclipse.persistence.internal.helper.DatabaseTable table,
org.eclipse.persistence.internal.sessions.AbstractRecord transRow,
org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow)
INTERNAL: returns the lock fields to compare based on the passed in
table.
|
java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> |
getLockFields()
INTERNAL: Returns the lock fields
|
protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> |
getLockFields(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL: returns the lock fields based on the passed in table
|
protected java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>> |
getLockFieldsByTable()
INTERNAL: returns the lock fields
|
void |
initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: It is responsible for initializing the policy;
|
void |
setLockFieldNames(java.util.List<java.lang.String> lockFieldNames)
PUBLIC: Set the field names to lock on.
|
protected void |
setLockFields(java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> lockFields)
INTERNAL: Sets the lock fields
|
protected void |
setLockFieldsByTable(java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>> lockFieldsByTable)
INTERNAL: Used to set the field names to be used in this policy.
|
addLockFieldsToUpdateRow, buildAllNonPrimaryKeyFields, buildDeleteExpression, buildExpression, buildUpdateExpression, clone, compareWriteLockValues, getAllNonPrimaryKeyFields, getAllNonPrimaryKeyFields, getBaseValue, getLockOnChangeMode, getValueToPutInCache, getVersionDifference, getWriteLockField, getWriteLockUpdateExpression, getWriteLockValue, initializeProperties, isCascaded, isNewerVersion, isNewerVersion, isPrimaryKey, isStoredInCache, mergeIntoParentCache, mergeIntoParentCache, setAllNonPrimaryKeyFields, setDescriptor, setLockOnChangeMode, setupWriteFieldsForInsert, shouldUpdateVersionOnMappingChange, shouldUpdateVersionOnOwnedMappingChange, supportsWriteLockValuesComparison, updateRowAndObjectForUpdate, validateDelete, validateUpdate, verifyUsage
protected java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>> lockFieldsByTable
protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> lockFields
public SelectedFieldsLockingPolicy()
public void addLockFieldName(java.lang.String fieldName)
public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query) throws DatabaseException
addLockValuesToTranslationRow
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
addLockValuesToTranslationRow
in class FieldsLockingPolicy
DatabaseException
protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getFieldsToCompare(org.eclipse.persistence.internal.helper.DatabaseTable table, org.eclipse.persistence.internal.sessions.AbstractRecord transRow, org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow)
getFieldsToCompare
in class FieldsLockingPolicy
public java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getLockFields()
protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getLockFields(org.eclipse.persistence.internal.helper.DatabaseTable table)
protected java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>> getLockFieldsByTable()
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
initialize
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
initialize
in class FieldsLockingPolicy
public void setLockFieldNames(java.util.List<java.lang.String> lockFieldNames)
protected void setLockFields(java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> lockFields)
protected void setLockFieldsByTable(java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>> lockFieldsByTable)