public abstract class FieldsLockingPolicy extends java.lang.Object implements 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 FormOptimisticLockingPolicy.LockOnChange| Constructor and Description |
|---|
FieldsLockingPolicy()
PUBLIC:
Create a new field locking policy.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLockFieldsToUpdateRow(AbstractRecord Record,
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.
|
Expression |
buildDeleteExpression(DatabaseTable table,
Expression mainExpression,
AbstractRecord row)
INTERNAL:
When given an expression, this method will return a new expression with the optimistic
locking values included.
|
Expression |
buildUpdateExpression(DatabaseTable table,
Expression mainExpression,
AbstractRecord transRow,
AbstractRecord modifyRow)
INTERNAL:
This method must be included in any locking policy.
|
java.lang.Object |
clone()
INTERNAL:
Clone the policy
|
int |
compareWriteLockValues(java.lang.Object value1,
java.lang.Object value2)
INTERNAL:
This method shouldn't be called if supportsWriteLockValuesComparison() returns false.
|
java.lang.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.
|
OptimisticLockingPolicy.LockOnChange |
getLockOnChangeMode()
ADVANCED:
returns the LockOnChange mode for this policy.
|
java.lang.Object |
getValueToPutInCache(AbstractRecord row,
AbstractSession session)
INTERNAL:
Return the value that should be stored in the identity map.
|
int |
getVersionDifference(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKeys,
AbstractSession session)
INTERNAL:
Return the number of version difference between the two states of the object.
|
DatabaseField |
getWriteLockField()
INTERNAL:
Return the write lock field.
|
Expression |
getWriteLockUpdateExpression(ExpressionBuilder builder,
AbstractSession session)
INTERNAL:
|
java.lang.Object |
getWriteLockValue(java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
INTERNAL:
This method will return the optimistic lock value for the object
|
void |
initialize(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(AbstractRecord Record,
java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
INTERNAL:
Compares the value from the row and from the object
(or cache).
|
boolean |
isNewerVersion(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
INTERNAL:
Compares the value and the value from the object
(or cache).
|
boolean |
isStoredInCache()
PUBLIC:
Return true if the lock value is stored in the cache.
|
void |
mergeIntoParentCache(CacheKey unitOfWorkCacheKey,
CacheKey parentSessionCacheKey)
INTERNAL:
This method should merge changes from the parent into the child.
|
void |
mergeIntoParentCache(UnitOfWorkImpl uow,
java.lang.Object primaryKey,
java.lang.Object object)
INTERNAL:
Only applicable when the value is stored in the cache.
|
void |
setDescriptor(ClassDescriptor descriptor)
INTERNAL: Set method for the descriptor
|
void |
setLockOnChangeMode(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,
java.lang.Object domainObject)
INTERNAL:
Nothing to do because all updates are handled by the application
|
void |
validateDelete(int rowCount,
java.lang.Object object,
DeleteObjectQuery query)
INTERNAL:
Check the row count for lock failure.
|
void |
validateUpdate(int rowCount,
java.lang.Object object,
WriteObjectQuery query)
INTERNAL:
Check the row count for lock failure.
|
public FieldsLockingPolicy()
public void addLockFieldsToUpdateRow(AbstractRecord Record, AbstractSession session)
addLockFieldsToUpdateRow in interface OptimisticLockingPolicypublic abstract void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
addLockValuesToTranslationRow in interface OptimisticLockingPolicypublic Expression buildDeleteExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row)
buildDeleteExpression in interface OptimisticLockingPolicypublic Expression buildUpdateExpression(DatabaseTable table, Expression mainExpression, AbstractRecord transRow, AbstractRecord modifyRow)
buildUpdateExpression in interface OptimisticLockingPolicypublic java.lang.Object clone()
clone in interface OptimisticLockingPolicyclone in class java.lang.Objectpublic boolean supportsWriteLockValuesComparison()
supportsWriteLockValuesComparison in interface OptimisticLockingPolicypublic int compareWriteLockValues(java.lang.Object value1,
java.lang.Object value2)
compareWriteLockValues in interface OptimisticLockingPolicypublic java.lang.Object getBaseValue()
getBaseValue in interface OptimisticLockingPolicypublic DatabaseField getWriteLockField()
getWriteLockField in interface OptimisticLockingPolicypublic Expression getWriteLockUpdateExpression(ExpressionBuilder builder, AbstractSession session)
getWriteLockUpdateExpression in interface OptimisticLockingPolicypublic OptimisticLockingPolicy.LockOnChange getLockOnChangeMode()
getLockOnChangeMode in interface OptimisticLockingPolicypublic java.lang.Object getValueToPutInCache(AbstractRecord row, AbstractSession session)
getValueToPutInCache in interface OptimisticLockingPolicypublic int getVersionDifference(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKeys,
AbstractSession session)
getVersionDifference in interface OptimisticLockingPolicypublic java.lang.Object getWriteLockValue(java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
getWriteLockValue in interface OptimisticLockingPolicypublic void initialize(AbstractSession session)
initialize in interface OptimisticLockingPolicypublic void initializeProperties()
initializeProperties in interface OptimisticLockingPolicypublic boolean isStoredInCache()
isStoredInCache in interface OptimisticLockingPolicypublic boolean isCascaded()
isCascaded in interface OptimisticLockingPolicypublic boolean isNewerVersion(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKey,
AbstractSession session)
isNewerVersion in interface OptimisticLockingPolicypublic boolean isNewerVersion(AbstractRecord Record, java.lang.Object domainObject, java.lang.Object primaryKey, AbstractSession session)
isNewerVersion in interface OptimisticLockingPolicypublic void mergeIntoParentCache(UnitOfWorkImpl uow, java.lang.Object primaryKey, java.lang.Object object)
mergeIntoParentCache in interface OptimisticLockingPolicypublic void mergeIntoParentCache(CacheKey unitOfWorkCacheKey, CacheKey parentSessionCacheKey)
mergeIntoParentCache in interface OptimisticLockingPolicypublic void setDescriptor(ClassDescriptor descriptor)
setDescriptor in interface OptimisticLockingPolicypublic void setLockOnChangeMode(OptimisticLockingPolicy.LockOnChange lockOnChangeMode)
setLockOnChangeMode in interface OptimisticLockingPolicypublic void setupWriteFieldsForInsert(ObjectLevelModifyQuery query)
setupWriteFieldsForInsert in interface OptimisticLockingPolicypublic void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, java.lang.Object domainObject)
updateRowAndObjectForUpdate in interface OptimisticLockingPolicypublic boolean shouldUpdateVersionOnOwnedMappingChange()
shouldUpdateVersionOnOwnedMappingChange in interface OptimisticLockingPolicypublic boolean shouldUpdateVersionOnMappingChange()
shouldUpdateVersionOnMappingChange in interface OptimisticLockingPolicypublic void validateDelete(int rowCount,
java.lang.Object object,
DeleteObjectQuery query)
validateDelete in interface OptimisticLockingPolicypublic void validateUpdate(int rowCount,
java.lang.Object object,
WriteObjectQuery query)
validateUpdate in interface OptimisticLockingPolicyEclipseLink 2.6.3, "build v20160428-59c81c5" API Reference