Top Inners Methods
org.eclipse.persistence.internal.descriptors

public Interface OptimisticLockingPolicy

extends Cloneable, Serializable
Known Direct Implementers
org.eclipse.persistence.descriptors.FieldsLockingPolicy, org.eclipse.persistence.descriptors.VersionLockingPolicy
Imports
java.io.Serializable, org.eclipse.persistence.expressions.*, org.eclipse.persistence.internal.helper.DatabaseField, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.queries.*, org.eclipse.persistence.internal.sessions.AbstractRecord, .UnitOfWorkImpl, .AbstractSession, org.eclipse.persistence.descriptors.ClassDescriptor

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
OptimisticLockingPolicy.LockOnChange

Advanced:

Purpose: Provides the configuration options to force an Optimistic Write Lock When a set of mappings have changes.

Method Summary

Modifier and TypeMethod and Description
public void
addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session)

INTERNAL: Add update fields for template row.

public void
addLockValuesToTranslationRow(ObjectLevelModifyQuery query)

INTERNAL: The method should update the translation row with the correct write lock values.

public 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.

public Expression
buildUpdateExpression(DatabaseTable table, Expression mainExpression, AbstractRecord translationRow, AbstractRecord modifyRow)

INTERNAL: When given an expression, this method will return a new expression with the optimistic locking values included.

public Object
public int
compareWriteLockValues(Object value1, Object value2)

INTERNAL: This method shouldn't be called if supportsWriteLockValuesComparison() returns false.

public <T> T
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.

public OptimisticLockingPolicy.LockOnChange
getLockOnChangeMode()

ADVANCED: returns the LockOnChange mode for this policy.

public <T> T
getValueToPutInCache(AbstractRecord row, AbstractSession session)

INTERNAL: Return the value that should be stored in the identity map.

public int
getVersionDifference(Object currentValue, Object domainObject, Object primaryKey, AbstractSession session)

PUBLIC: Return the number of versions different between these objects.

public DatabaseField
getWriteLockField()

INTERNAL: Return the write lock field.

public Expression
getWriteLockUpdateExpression(ExpressionBuilder builder, AbstractSession session)

INTERNAL: This method will return an expression that is used to update its optimistic locking field #see this method in VersionLockingPolicy

public <T> T
getWriteLockValue(Object domainObject, Object primaryKey, AbstractSession session)

INTERNAL: This method will return the optimistic lock value for the object #see this method in VersionLockingPolicy

public void
initialize(AbstractSession session)

INTERNAL: It is responsible for initializing the policy.

public void
initializeProperties()

INTERNAL: Responsible for pre-initializing.

public boolean
isCascaded()

INTERNAL: Specify if the policy cascade locks.

public boolean
isNewerVersion(Object currentValue, Object domainObject, Object primaryKey, AbstractSession session)

INTERNAL: Returns true if the value stored with the domainObject is more recent than the value .

public boolean
isNewerVersion(AbstractRecord databaseRow, Object domainObject, Object primaryKey, AbstractSession session)

INTERNAL: Returns true if the value stored with the domainObject is more recent than the value in the row.

public boolean
isStoredInCache()

INTERNAL: Return true if the lock value is stored in the cache.

public void
mergeIntoParentCache(UnitOfWorkImpl uow, Object primaryKey, Object object)

INTERNAL: This method should merge changes from the parent into the child.

public void
mergeIntoParentCache(CacheKey unitOfWorkCacheKey, CacheKey parentSessionCacheKey)

INTERNAL: This method should merge changes from the parent into the child.

public void
setDescriptor(ClassDescriptor descriptor)

INTERNAL: provide a way to set the descriptor for this policy

public void
setLockOnChangeMode(OptimisticLockingPolicy.LockOnChange lockOnChangeMode)

ADVANCED: Sets the LockOnChange mode for this policy.

public void
setupWriteFieldsForInsert(ObjectLevelModifyQuery query)

INTERNAL: Add the initial right lock values to the modify row in the query.

public boolean
shouldUpdateVersionOnMappingChange()

INTERNAL: Returns true if the policy has been set to set an optimistic read lock when any mapping changes.

public boolean
shouldUpdateVersionOnOwnedMappingChange()

INTERNAL: Returns true if the policy has been set to set an optimistic read lock when a owning mapping changes.

public boolean
supportsWriteLockValuesComparison()

INTERNAL: Indicates whether compareWriteLockValues method is supported by the policy.

public void
updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object object)

INTERNAL: This method should update the translation row, the modify row and the domain object with th lock value.

public void
validateDelete(int rowCount, Object object, DeleteObjectQuery query)

public void
validateUpdate(int rowCount, Object object, WriteObjectQuery query)

Method Detail

addLockFieldsToUpdateRowback to summary
public void addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session)

INTERNAL: Add update fields for template row. These are any unmapped fields required to write in an update. #see this method in VersionLockingPolicy

addLockValuesToTranslationRowback to summary
public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)

INTERNAL: The method should update the translation row with the correct write lock values. This method is called on a delete. #see this method in VersionLockingPolicy

buildDeleteExpressionback to summary
public 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. This expression will be used in a delete call. #see this method in VersionLockingPolicy

buildUpdateExpressionback to summary
public Expression buildUpdateExpression(DatabaseTable table, Expression mainExpression, AbstractRecord translationRow, AbstractRecord modifyRow)

INTERNAL: When given an expression, this method will return a new expression with the optimistic locking values included. This expression will be used in an update call. #see this method in VersionLockingPolicy

cloneback to summary
public Object clone()
compareWriteLockValuesback to summary
public int compareWriteLockValues(Object value1, Object value2)

INTERNAL: This method shouldn't be called if supportsWriteLockValuesComparison() returns false. This method compares two writeLockValues. The writeLockValues should be non-null and of the correct type. Returns: -1 if value1 is less (older) than value2; 0 if value1 equals value2; 1 if value1 is greater (newer) than value2. Throws: NullPointerException if the passed value is null; ClassCastException if the passed value is of a wrong type.

getBaseValueback to summary
public <T> T 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.

getLockOnChangeModeback to summary
public OptimisticLockingPolicy.LockOnChange getLockOnChangeMode()

ADVANCED: returns the LockOnChange mode for this policy. This mode specifies if a Optimistic Write lock should be enforced on this entity when a set of mappings are changed.

getValueToPutInCacheback to summary
public <T> T getValueToPutInCache(AbstractRecord row, AbstractSession session)

INTERNAL: Return the value that should be stored in the identity map. If the value is not stored in the cache, then return a null. #see this method in VersionLockingPolicy

getVersionDifferenceback to summary
public int getVersionDifference(Object currentValue, Object domainObject, Object primaryKey, AbstractSession session)

PUBLIC: Return the number of versions different between these objects.

getWriteLockFieldback to summary
public DatabaseField getWriteLockField()

INTERNAL: Return the write lock field. #see this method in VersionLockingPolicy

getWriteLockUpdateExpressionback to summary
public Expression getWriteLockUpdateExpression(ExpressionBuilder builder, AbstractSession session)

INTERNAL: This method will return an expression that is used to update its optimistic locking field #see this method in VersionLockingPolicy

getWriteLockValueback to summary
public <T> T getWriteLockValue(Object domainObject, Object primaryKey, AbstractSession session)

INTERNAL: This method will return the optimistic lock value for the object #see this method in VersionLockingPolicy

initializeback to summary
public void initialize(AbstractSession session)

INTERNAL: It is responsible for initializing the policy. #see this method in VersionLockingPolicy

initializePropertiesback to summary
public void initializeProperties()

INTERNAL: Responsible for pre-initializing. #see this method in VersionLockingPolicy

isCascadedback to summary
public boolean isCascaded()

INTERNAL: Specify if the policy cascade locks.

isNewerVersionback to summary
public boolean isNewerVersion(Object currentValue, Object domainObject, Object primaryKey, AbstractSession session)

INTERNAL: Returns true if the value stored with the domainObject is more recent than the value . Returns false otherwise. #see this method in VersionLockingPolicy

isNewerVersionback to summary
public boolean isNewerVersion(AbstractRecord databaseRow, Object domainObject, Object primaryKey, AbstractSession session)

INTERNAL: Returns true if the value stored with the domainObject is more recent than the value in the row. Returns false otherwise.

Note

This method will only be called if the shouldOnlyRefreshCacheIfNewerVersion() flag is set on descriptor. #see this method in VersionLockingPolicy

isStoredInCacheback to summary
public boolean isStoredInCache()

INTERNAL: Return true if the lock value is stored in the cache.

mergeIntoParentCacheback to summary
public void mergeIntoParentCache(UnitOfWorkImpl uow, Object primaryKey, Object object)

INTERNAL: This method should merge changes from the parent into the child. #see this method in VersionLockingPolicy

mergeIntoParentCacheback to summary
public void mergeIntoParentCache(CacheKey unitOfWorkCacheKey, CacheKey parentSessionCacheKey)

INTERNAL: This method should merge changes from the parent into the child. #see this method in VersionLockingPolicy

setDescriptorback to summary
public void setDescriptor(ClassDescriptor descriptor)

INTERNAL: provide a way to set the descriptor for this policy

setLockOnChangeModeback to summary
public void setLockOnChangeMode(OptimisticLockingPolicy.LockOnChange lockOnChangeMode)

ADVANCED: Sets the LockOnChange mode for this policy. This mode specifies if a Optimistic Write lock should be enforced on this entity when set of mappings are changed.

setupWriteFieldsForInsertback to summary
public void setupWriteFieldsForInsert(ObjectLevelModifyQuery query)

INTERNAL: Add the initial right lock values to the modify row in the query. This method will only be called on insert. #see this method in VersionLockingPolicy

shouldUpdateVersionOnMappingChangeback to summary
public boolean shouldUpdateVersionOnMappingChange()

INTERNAL: Returns true if the policy has been set to set an optimistic read lock when any mapping changes.

shouldUpdateVersionOnOwnedMappingChangeback to summary
public boolean shouldUpdateVersionOnOwnedMappingChange()

INTERNAL: Returns true if the policy has been set to set an optimistic read lock when a owning mapping changes.

supportsWriteLockValuesComparisonback to summary
public boolean supportsWriteLockValuesComparison()

INTERNAL: Indicates whether compareWriteLockValues method is supported by the policy. Numeric or timestamp lock values could be compared: for every pair of values v1 and v2 - either v1 lessthan v2; or v1==v2; or v1 greaterthan v2. However it's impossible to compare values for FieldsLockingPolicy for two reasons: 1. there is no "linear order": v1 lessthan v2 and v greaterthan v2 is not defined: either v1==v2 or v1!=v2; 2. locking value is not a single field which is not part of mapped object value but rather a set of object's mapped fields. That means any object's mapped attribute change is potentially a change of the locking value. For ChangedFieldsLockingPolicy every mapped attribute's change is a change of locking value. The pattern used by versioning: "if the original locking value is unchanged then the object hasn't been changed outside of the application", which allows to distinguish between the change made inside and outside the application, doesn't work for fields locking. It degenerates into useless pattern: "if the original locking value is unchanged then the object hasn't been changed". Use compareWriteLockValues method only if this method returns true.

updateRowAndObjectForUpdateback to summary
public void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object object)

INTERNAL: This method should update the translation row, the modify row and the domain object with th lock value. #see this method in VersionLockingPolicy

validateDeleteback to summary
public void validateDelete(int rowCount, Object object, DeleteObjectQuery query)
validateUpdateback to summary
public void validateUpdate(int rowCount, Object object, WriteObjectQuery query)
org.eclipse.persistence.internal.descriptors back to summary

public final Enum OptimisticLockingPolicy.LockOnChange

extends Enum<OptimisticLockingPolicy.LockOnChange>
Class Inheritance

Advanced:

Purpose: Provides the configuration options to force an Optimistic Write Lock When a set of mappings have changes. This enum defines what mappings are within that set.

Author
Gordon Yorke
Since
EclipseLink 2.0

Field Summary

Modifier and TypeField and Description
public static final OptimisticLockingPolicy.LockOnChange
public static final OptimisticLockingPolicy.LockOnChange
public static final OptimisticLockingPolicy.LockOnChange

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static OptimisticLockingPolicy.LockOnChange
public static OptimisticLockingPolicy.LockOnChange[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALLback to summary
public static final OptimisticLockingPolicy.LockOnChange ALL
NONEback to summary
public static final OptimisticLockingPolicy.LockOnChange NONE
OWNINGback to summary
public static final OptimisticLockingPolicy.LockOnChange OWNING

Constructor Detail

LockOnChangeback to summary
private LockOnChange()

Method Detail

valueOfback to summary
public static OptimisticLockingPolicy.LockOnChange valueOf(String name)
valuesback to summary
public static OptimisticLockingPolicy.LockOnChange[] values()