|
EclipseLink 2.2.0, build 'v20110202-r8913' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.persistence.descriptors.VersionLockingPolicy
public class VersionLockingPolicy
Purpose: Used to allow a single version number to be used for optimistic locking.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy |
---|
org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange |
Field Summary | |
---|---|
protected Expression |
cachedExpression
|
protected ClassDescriptor |
descriptor
|
static int |
IN_CACHE
|
static int |
IN_OBJECT
|
protected boolean |
isCascaded
|
protected AbstractDirectMapping |
lockMapping
PERF: Cache the lock mapping if mapped with a direct mapping. |
protected org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange |
lockOnChangeMode
|
protected int |
lockValueStored
|
protected org.eclipse.persistence.internal.helper.DatabaseField |
writeLockField
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
protected Expression |
buildExpression()
INTERNAL: Returns an expression that will be used for both the update and delete where clause |
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. |
protected java.lang.Class |
getDefaultLockingFieldType()
INTERNAL: Return the default version locking filed java type, default is BigDecimal |
protected ClassDescriptor |
getDescriptor()
INTERNAL: |
protected java.lang.Object |
getInitialWriteValue(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: returns the initial locking value |
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. |
protected java.util.Vector |
getUnmappedFields()
INTERNAL: This method returns any of the fields that are not mapped in the object. |
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 |
protected java.lang.Number |
incrementWriteLockValue(java.lang.Number numberValue)
INTERNAL: Adds 1 to the value passed in. |
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. |
protected java.lang.Object |
lockValueFromObject(java.lang.Object domainObject)
INTERNAL: Retrieves the lock value from the object. |
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. |
protected void |
updateWriteLockValueForWrite(ObjectLevelModifyQuery query,
java.lang.Object lockValue)
INTERNAL: Update the row, object and change set with the version 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. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.eclipse.persistence.internal.helper.DatabaseField writeLockField
protected boolean isCascaded
protected int lockValueStored
protected ClassDescriptor descriptor
protected transient Expression cachedExpression
public static final int IN_CACHE
public static final int IN_OBJECT
protected AbstractDirectMapping lockMapping
protected org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange lockOnChangeMode
Constructor Detail |
---|
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.Method Detail |
---|
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.OptimisticLockingPolicy
public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
addLockValuesToTranslationRow
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
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.OptimisticLockingPolicy
protected Expression buildExpression()
public 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.OptimisticLockingPolicy
public java.lang.Object clone()
clone
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
clone
in class java.lang.Object
public 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.OptimisticLockingPolicy
protected java.lang.Class getDefaultLockingFieldType()
public java.lang.Object getBaseValue()
getBaseValue
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
protected ClassDescriptor getDescriptor()
protected java.lang.Object getInitialWriteValue(org.eclipse.persistence.internal.sessions.AbstractSession session)
public org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange getLockOnChangeMode()
getLockOnChangeMode
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public java.lang.Object getNewLockValue(ModifyQuery query)
protected java.util.Vector getUnmappedFields()
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.OptimisticLockingPolicy
currentValue
- 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.OptimisticLockingPolicy
public 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.OptimisticLockingPolicy
protected java.lang.Number incrementWriteLockValue(java.lang.Number numberValue)
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
initialize
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public void initializeProperties()
initializeProperties
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public 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.OptimisticLockingPolicy
public boolean isStoredInObject()
protected java.lang.Object lockValueFromObject(java.lang.Object domainObject)
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 setDescriptor(ClassDescriptor descriptor)
setDescriptor
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public 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.OptimisticLockingPolicy
protected void updateWriteLockValueForWrite(ObjectLevelModifyQuery query, java.lang.Object lockValue)
public boolean shouldUpdateVersionOnOwnedMappingChange()
shouldUpdateVersionOnOwnedMappingChange
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public boolean shouldUpdateVersionOnMappingChange()
shouldUpdateVersionOnMappingChange
in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
public 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.OptimisticLockingPolicy
public 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.OptimisticLockingPolicy
public 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
|
EclipseLink 2.2.0, build 'v20110202-r8913' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |