public class VersionLockingPolicy
extends java.lang.Object
implements org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy, java.io.Serializable
Purpose: Used to allow a single version number to be used for optimistic locking.
| Modifier and Type | Field and Description |
|---|---|
static int |
IN_CACHE |
static int |
IN_OBJECT |
| Constructor and Description |
|---|
VersionLockingPolicy()
PUBLIC: Create a new VersionLockingPolicy.
|
VersionLockingPolicy(org.eclipse.persistence.internal.helper.DatabaseField field)
PUBLIC: Create a new VersionLockingPolicy.
|
VersionLockingPolicy(java.lang.String fieldName)
PUBLIC: Create a new VersionLockingPolicy.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLockFieldsToUpdateRow(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Add update fields for template row.
|
void |
addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
INTERNAL: This method adds the lock value to the translation row of the passed in query. depending on the storage flag, the value is either retrieved from the cache of the object.
|
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.
|
Expression |
buildUpdateExpression(org.eclipse.persistence.internal.helper.DatabaseTable table, Expression mainExpression, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractRecord row2)
INTERNAL: When given an expression, this method will return a new expression with the optimistic locking values included.
|
java.lang.Object |
clone()
INTERNAL: Clone the policy
|
int |
compareWriteLockValues(java.lang.Object value1, java.lang.Object value2)
INTERNAL: This method compares two writeLockValues.
|
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.
|
org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange |
getLockOnChangeMode()
ADVANCED: returns the LockOnChange mode for this policy.
|
java.lang.Object |
getNewLockValue(ModifyQuery query)
INTERNAL: This method gets the write lock value from either the cache or the object stored in the query.
|
java.lang.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(java.lang.Object currentValue, java.lang.Object domainObject, java.lang.Object primaryKeys, org.eclipse.persistence.internal.sessions.AbstractSession session)
PUBLIC: Return the number of versions different between these objects.
|
AbstractDirectMapping |
getVersionMapping()
INTERNAL: Returns the mapping that will be used to access the version value from an object.
|
org.eclipse.persistence.internal.helper.DatabaseField |
getWriteLockField()
INTERNAL: Return the write lock field.
|
java.lang.String |
getWriteLockFieldName()
PUBLIC: Return the field name of the field that stores the write lock value.
|
Expression |
getWriteLockUpdateExpression(ExpressionBuilder builder, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Retrun an expression that updates the write lock
|
java.lang.Object |
getWriteLockValue(java.lang.Object domainObject, java.lang.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 properties;
|
boolean |
isCascaded()
PUBLIC: Return true if the policy uses cascade locking.
|
boolean |
isNewerVersion(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow, java.lang.Object domainObject, java.lang.Object primaryKey, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Compares the value from the row and from the object (or cache).
|
boolean |
isNewerVersion(java.lang.Object firstLockFieldValue, java.lang.Object secondWriteLockFieldValue)
INTERNAL: Compares two values.
|
boolean |
isNewerVersion(java.lang.Object currentValue, java.lang.Object domainObject, java.lang.Object primaryKey, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Compares the value with the value from the object (or cache).
|
boolean |
isStoredInCache()
PUBLIC: Return true if the lock value is stored in the cache.
|
boolean |
isStoredInObject()
PUBLIC: Return true if the lock value is stored in the object.
|
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, java.lang.Object primaryKey, java.lang.Object object)
INTERNAL: Only applicable when the value is stored in the cache.
|
void |
setDescriptor(ClassDescriptor descriptor)
INTERNAL:
|
void |
setIsCascaded(boolean isCascaded)
PUBLIC: Set whether to use cascade locking on the policy.
|
void |
setIsStoredInCache(boolean isStoredInCache)
PUBLIC: Set whether to store the lock in the cache or in the object.
|
void |
setLockOnChangeMode(org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange lockOnChangeMode)
ADVANCED: Sets the LockOnChange mode for this policy.
|
void |
setupWriteFieldsForInsert(ObjectLevelModifyQuery query)
INTERNAL: This method must be included in any locking policy.
|
void |
setWriteLockField(org.eclipse.persistence.internal.helper.DatabaseField writeLockField)
ADVANCED: Set the write lock field.
|
void |
setWriteLockFieldName(java.lang.String writeLockFieldName)
PUBLIC: Set the write lock field name.
|
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.
|
void |
storeInCache()
PUBLIC: Configure the version lock value to be stored in the cache.
|
void |
storeInObject()
PUBLIC: Configure the version lock value to be stored in the object.
|
boolean |
supportsWriteLockValuesComparison()
INTERNAL: Indicates that compareWriteLockValues method is supported by the policy.
|
void |
updateObjectWithWriteValue(ObjectLevelModifyQuery query, java.lang.Object lockValue) |
void |
updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, java.lang.Object domainObject)
INTERNAL: This method updates the modify row, and the domain object with the new lock value.
|
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.
|
void |
writeLockValueIntoRow(ObjectLevelModifyQuery query, java.lang.Object domainObject)
INTERNAL: This method updates the modify row with the old lock value.
|
public static final int IN_CACHE
public static final int IN_OBJECT
public VersionLockingPolicy()
public VersionLockingPolicy(java.lang.String fieldName)
fieldName - specifies the field name for the write lock field.public VersionLockingPolicy(org.eclipse.persistence.internal.helper.DatabaseField field)
field - the write lock field.
public void addLockFieldsToUpdateRow(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
org.eclipse.persistence.internal.sessions.AbstractSession session)
addLockFieldsToUpdateRow in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
addLockValuesToTranslationRow in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic 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.OptimisticLockingPolicypublic Expression buildUpdateExpression(org.eclipse.persistence.internal.helper.DatabaseTable table, Expression mainExpression, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractRecord row2)
buildUpdateExpression in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic java.lang.Object clone()
clone in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicyclone in class java.lang.Objectpublic boolean supportsWriteLockValuesComparison()
supportsWriteLockValuesComparison in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public int compareWriteLockValues(java.lang.Object value1,
java.lang.Object value2)
compareWriteLockValues in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic java.lang.Object getBaseValue()
getBaseValue 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 java.lang.Object getNewLockValue(ModifyQuery query)
public java.lang.Object getValueToPutInCache(org.eclipse.persistence.internal.sessions.AbstractRecord row,
org.eclipse.persistence.internal.sessions.AbstractSession session)
getValueToPutInCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public int getVersionDifference(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKeys,
org.eclipse.persistence.internal.sessions.AbstractSession session)
getVersionDifference in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicycurrentValue - the new lock valuedomainObject - the object containing the version to be compared toprimaryKeys - a vector containing the primary keys of the domainObjectsession - the session to be used with the comparisonpublic org.eclipse.persistence.internal.helper.DatabaseField getWriteLockField()
getWriteLockField in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic java.lang.String getWriteLockFieldName()
public Expression getWriteLockUpdateExpression(ExpressionBuilder builder, org.eclipse.persistence.internal.sessions.AbstractSession session)
getWriteLockUpdateExpression in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public java.lang.Object getWriteLockValue(java.lang.Object domainObject,
java.lang.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 isCascaded()
isCascaded in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public boolean isNewerVersion(java.lang.Object currentValue,
java.lang.Object domainObject,
java.lang.Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
isNewerVersion in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public boolean isNewerVersion(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
java.lang.Object domainObject,
java.lang.Object primaryKey,
org.eclipse.persistence.internal.sessions.AbstractSession session)
isNewerVersion in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public boolean isNewerVersion(java.lang.Object firstLockFieldValue,
java.lang.Object secondWriteLockFieldValue)
public boolean isStoredInCache()
isStoredInCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic boolean isStoredInObject()
public AbstractDirectMapping getVersionMapping()
public void mergeIntoParentCache(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
java.lang.Object primaryKey,
java.lang.Object object)
mergeIntoParentCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public void mergeIntoParentCache(org.eclipse.persistence.internal.identitymaps.CacheKey unitOfWorkCacheKey,
org.eclipse.persistence.internal.identitymaps.CacheKey parentSessionCacheKey)
mergeIntoParentCache in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void setDescriptor(ClassDescriptor descriptor)
setDescriptor in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void setIsStoredInCache(boolean isStoredInCache)
isStoredInCache - set this to true if you would like to store lock in the cache and set it to false if you would like to store it in the object.public void setIsCascaded(boolean isCascaded)
isCascaded - set this to true if you would like cascade the locking and set it to false if you would like no cascade locking.public void setupWriteFieldsForInsert(ObjectLevelModifyQuery query)
setupWriteFieldsForInsert 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 updateObjectWithWriteValue(ObjectLevelModifyQuery query, java.lang.Object lockValue)
public void setLockOnChangeMode(org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange lockOnChangeMode)
setLockOnChangeMode in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void setWriteLockField(org.eclipse.persistence.internal.helper.DatabaseField writeLockField)
public void setWriteLockFieldName(java.lang.String writeLockFieldName)
writeLockFieldName - the name of the field to lock against.public void storeInCache()
public void storeInObject()
public void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, java.lang.Object domainObject)
updateRowAndObjectForUpdate in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicypublic void writeLockValueIntoRow(ObjectLevelModifyQuery query, java.lang.Object domainObject)
public void validateDelete(int rowCount,
java.lang.Object object,
DeleteObjectQuery query)
validateDelete in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public void validateUpdate(int rowCount,
java.lang.Object object,
WriteObjectQuery query)
validateUpdate in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy