public abstract class FieldsLockingPolicy extends Object implements org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
Purpose: An abstract superclass of some implementations of the OptimisticLockingPolicy interface. All of the subclasses of this class implement OptimisticLocking based on mapped fields in the object. These fields are only compared and not modified. Any modification (incrementing etc..) must be handled by the application.
AllFieldsLockingPolicy,
ChangedFieldsLockingPolicy,
SelectedFieldsLockingPolicy,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected List<org.eclipse.persistence.internal.helper.DatabaseField> |
allNonPrimaryKeyFields |
protected ClassDescriptor |
descriptor |
| Constructor and Description |
|---|
FieldsLockingPolicy()
PUBLIC:
Create a new field locking policy.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLockFieldsToUpdateRow(org.eclipse.persistence.internal.sessions.AbstractRecord Record,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Add update fields for template row.
|
abstract void |
addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
INTERNAL:
Values to be included in the locking mechanism are added
to the translation row.
|
protected List |
buildAllNonPrimaryKeyFields()
INTERNAL:
Returns the fields that should be compared in the where clause.
|
Expression |
buildDeleteExpression(org.eclipse.persistence.internal.helper.DatabaseTable table,
Expression mainExpression,
org.eclipse.persistence.internal.sessions.AbstractRecord row)
INTERNAL:
When given an expression, this method will return a new expression with the optimistic
locking values included.
|
protected Expression |
buildExpression(org.eclipse.persistence.internal.helper.DatabaseTable table,
org.eclipse.persistence.internal.sessions.AbstractRecord transRow,
org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow,
ExpressionBuilder builder)
INTERNAL:
returns the expression to be used in both the delete and update where clause.
|
Expression |
buildUpdateExpression(org.eclipse.persistence.internal.helper.DatabaseTable table,
Expression mainExpression,
org.eclipse.persistence.internal.sessions.AbstractRecord transRow,
org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow)
INTERNAL:
This method must be included in any locking policy.
|
Object |
clone()
INTERNAL:
Clone the policy
|
int |
compareWriteLockValues(Object value1,
Object value2)
INTERNAL:
This method shouldn't be called if supportsWriteLockValuesComparison() returns false.
|
protected List<org.eclipse.persistence.internal.helper.DatabaseField> |
getAllNonPrimaryKeyFields()
INTERNAL:
Returns the fields that should be compared in the where clause.
|
protected List<org.eclipse.persistence.internal.helper.DatabaseField> |
getAllNonPrimaryKeyFields(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL:
filter the fields based on the passed in table.
|
Object |
getBaseValue()
INTERNAL:
This is the base value that is older than all other values, it is used in the place of
null in some situations.
|
protected abstract 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 fields that should be compared in the where clause.
|
org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange |
getLockOnChangeMode()
ADVANCED:
returns the LockOnChange mode for this policy.
|
Object |
getValueToPutInCache(org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Return the value that should be stored in the identity map.
|
int |
getVersionDifference(Object currentValue,
Object domainObject,
Object primaryKeys,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Return the number of version difference between the two states of the object.
|
org.eclipse.persistence.internal.helper.DatabaseField |
getWriteLockField()
INTERNAL:
Return the write lock field.
|
Expression |
getWriteLockUpdateExpression(ExpressionBuilder builder,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
|
Object |
getWriteLockValue(Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
This method will return the optimistic lock value for the object
|
void |
initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
It is responsible for initializing the policy;
|
void |
initializeProperties()
INTERNAL:
It is responsible for initializing the policy;
|
boolean |
isCascaded()
PUBLIC:
Return true if the policy uses cascade locking.
|
boolean |
isNewerVersion(org.eclipse.persistence.internal.sessions.AbstractRecord Record,
Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Compares the value from the row and from the object
(or cache).
|
boolean |
isNewerVersion(Object currentValue,
Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
Compares the value and the value from the object
(or cache).
|
protected boolean |
isPrimaryKey(org.eclipse.persistence.internal.helper.DatabaseField dbField)
INTERNAL:
Returns whether or not this field is a primary key.
|
boolean |
isStoredInCache()
PUBLIC:
Return true if the lock value is stored in the cache.
|
void |
mergeIntoParentCache(org.eclipse.persistence.internal.identitymaps.CacheKey unitOfWorkCacheKey,
org.eclipse.persistence.internal.identitymaps.CacheKey parentSessionCacheKey)
INTERNAL:
This method should merge changes from the parent into the child.
|
void |
mergeIntoParentCache(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
Object primaryKey,
Object object)
INTERNAL:
Only applicable when the value is stored in the cache.
|
protected void |
setAllNonPrimaryKeyFields(List allNonPrimaryKeyFields)
INTERNAL: Set method for all the primary keys
|
void |
setDescriptor(ClassDescriptor descriptor)
INTERNAL: Set method for the descriptor
|
void |
setLockOnChangeMode(org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange lockOnChangeMode)
ADVANCED:
Sets the LockOnChange mode for this policy.
|
void |
setupWriteFieldsForInsert(ObjectLevelModifyQuery query)
INTERNAL:
Put the initial writelock value into the modifyRow.
|
boolean |
shouldUpdateVersionOnMappingChange()
INTERNAL:
Returns true if the policy has been set to set an optimistic read lock when any mapping changes.
|
boolean |
shouldUpdateVersionOnOwnedMappingChange()
INTERNAL:
Returns true if the policy has been set to set an optimistic read lock when a owning mapping changes.
|
boolean |
supportsWriteLockValuesComparison()
INTERNAL:
Indicates whether compareWriteLockValues method is supported by the policy.
|
void |
updateRowAndObjectForUpdate(ObjectLevelModifyQuery query,
Object domainObject)
INTERNAL:
Nothing to do because all updates are handled by the application
|
void |
validateDelete(int rowCount,
Object object,
DeleteObjectQuery query)
INTERNAL:
Check the row count for lock failure.
|
void |
validateUpdate(int rowCount,
Object object,
WriteObjectQuery query)
INTERNAL:
Check the row count for lock failure.
|
protected void |
verifyUsage(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL:
throw an exception if not inside a unit of work at this point
|
protected ClassDescriptor descriptor
protected List<org.eclipse.persistence.internal.helper.DatabaseField> allNonPrimaryKeyFields
public FieldsLockingPolicy()
public void addLockFieldsToUpdateRow(org.eclipse.persistence.internal.sessions.AbstractRecord Record,
org.eclipse.persistence.internal.sessions.AbstractSession session)
addLockFieldsToUpdateRow in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic abstract void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
addLockValuesToTranslationRow in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyprotected List buildAllNonPrimaryKeyFields()
public Expression buildDeleteExpression(org.eclipse.persistence.internal.helper.DatabaseTable table, Expression mainExpression, org.eclipse.persistence.internal.sessions.AbstractRecord row)
buildDeleteExpression in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyprotected Expression buildExpression(org.eclipse.persistence.internal.helper.DatabaseTable table, org.eclipse.persistence.internal.sessions.AbstractRecord transRow, org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow, ExpressionBuilder builder)
public Expression buildUpdateExpression(org.eclipse.persistence.internal.helper.DatabaseTable table, Expression mainExpression, org.eclipse.persistence.internal.sessions.AbstractRecord transRow, org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow)
buildUpdateExpression in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic Object clone()
public boolean supportsWriteLockValuesComparison()
supportsWriteLockValuesComparison in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic int compareWriteLockValues(Object value1, Object value2)
compareWriteLockValues in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyprotected List<org.eclipse.persistence.internal.helper.DatabaseField> getAllNonPrimaryKeyFields()
protected List<org.eclipse.persistence.internal.helper.DatabaseField> getAllNonPrimaryKeyFields(org.eclipse.persistence.internal.helper.DatabaseTable table)
public Object getBaseValue()
getBaseValue in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyprotected abstract 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)
public org.eclipse.persistence.internal.helper.DatabaseField getWriteLockField()
getWriteLockField in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic Expression getWriteLockUpdateExpression(ExpressionBuilder builder, org.eclipse.persistence.internal.sessions.AbstractSession session)
getWriteLockUpdateExpression in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange getLockOnChangeMode()
getLockOnChangeMode in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic Object getValueToPutInCache(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
getValueToPutInCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic int getVersionDifference(Object currentValue, Object domainObject, Object primaryKeys, org.eclipse.persistence.internal.sessions.AbstractSession session)
getVersionDifference in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic Object getWriteLockValue(Object domainObject, Object primaryKey, org.eclipse.persistence.internal.sessions.AbstractSession session)
getWriteLockValue in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
initialize in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void initializeProperties()
initializeProperties in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic boolean isStoredInCache()
isStoredInCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic boolean isCascaded()
isCascaded in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic boolean isNewerVersion(Object currentValue, Object domainObject, Object primaryKey, org.eclipse.persistence.internal.sessions.AbstractSession session)
isNewerVersion in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic boolean isNewerVersion(org.eclipse.persistence.internal.sessions.AbstractRecord Record,
Object domainObject,
Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
isNewerVersion in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyprotected boolean isPrimaryKey(org.eclipse.persistence.internal.helper.DatabaseField dbField)
public void mergeIntoParentCache(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
Object primaryKey,
Object object)
mergeIntoParentCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void mergeIntoParentCache(org.eclipse.persistence.internal.identitymaps.CacheKey unitOfWorkCacheKey,
org.eclipse.persistence.internal.identitymaps.CacheKey parentSessionCacheKey)
mergeIntoParentCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyprotected void setAllNonPrimaryKeyFields(List allNonPrimaryKeyFields)
public void setDescriptor(ClassDescriptor descriptor)
setDescriptor in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void setLockOnChangeMode(org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange lockOnChangeMode)
setLockOnChangeMode in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void setupWriteFieldsForInsert(ObjectLevelModifyQuery query)
setupWriteFieldsForInsert in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object domainObject)
updateRowAndObjectForUpdate in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic boolean shouldUpdateVersionOnOwnedMappingChange()
shouldUpdateVersionOnOwnedMappingChange in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic boolean shouldUpdateVersionOnMappingChange()
shouldUpdateVersionOnMappingChange in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void validateDelete(int rowCount,
Object object,
DeleteObjectQuery query)
validateDelete in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void validateUpdate(int rowCount,
Object object,
WriteObjectQuery query)
validateUpdate in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyprotected void verifyUsage(org.eclipse.persistence.internal.sessions.AbstractSession session)
Copyright © 2007–2021 Eclipse.org - EclipseLink Project. All rights reserved.