|
EclipseLink 1.0_1.0M2 API Reference - Incubation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.persistence.descriptors.VersionLockingPolicy
public class VersionLockingPolicy
Purpose: Used to allow a single version number to be used for optimistic locking.
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 int |
lockValueStored
|
protected DatabaseField |
writeLockField
|
Constructor Summary | |
---|---|
VersionLockingPolicy()
PUBLIC: Create a new VersionLockingPolicy. |
|
VersionLockingPolicy(java.lang.String fieldName)
PUBLIC: Create a new VersionLockingPolicy. |
Method Summary | |
---|---|
void |
addLockFieldsToUpdateRow(AbstractRecord databaseRow,
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(DatabaseTable table,
Expression mainExpression,
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(DatabaseTable table,
Expression mainExpression,
AbstractRecord row,
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(AbstractSession session)
INTERNAL: returns the initial locking value |
protected 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(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.util.Vector primaryKeys,
AbstractSession session)
PUBLIC: Return the number of versions different between these objects. |
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)
INTERNAL: Retrun an expression that updates the write lock |
java.lang.Object |
getWriteLockValue(java.lang.Object domainObject,
java.util.Vector primaryKey,
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(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 |
isChildWriteLockValueGreater(AbstractSession session,
java.util.Vector primaryKey,
java.lang.Class original,
ObjectChangeSet changeSet)
INTERNAL: Update the parent write lock value if the unit of works has been incremented. |
boolean |
isNewerVersion(java.lang.Object currentValue,
java.lang.Object domainObject,
java.util.Vector primaryKey,
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(UnitOfWorkImpl uow,
java.util.Vector 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 |
setupWriteFieldsForInsert(ObjectLevelModifyQuery query)
INTERNAL: This method must be included in any locking policy. |
void |
setWriteLockField(DatabaseField writeLockField)
ADVANCED: Set the write lock field. |
void |
setWriteLockFieldName(java.lang.String writeLockFieldName)
PUBLIC: Set the write lock field name. |
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 |
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 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
Constructor Detail |
---|
public VersionLockingPolicy()
public VersionLockingPolicy(java.lang.String fieldName)
fieldName
- specifies the field name for the write
lock field.Method Detail |
---|
public void addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session)
public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
public Expression buildDeleteExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row)
protected Expression buildExpression()
public Expression buildUpdateExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row, AbstractRecord row2)
public java.lang.Object clone()
clone
in class java.lang.Object
public boolean supportsWriteLockValuesComparison()
public int compareWriteLockValues(java.lang.Object value1, java.lang.Object value2)
protected java.lang.Class getDefaultLockingFieldType()
public java.lang.Object getBaseValue()
protected ClassDescriptor getDescriptor()
protected java.lang.Object getInitialWriteValue(AbstractSession session)
protected java.lang.Object getNewLockValue(ModifyQuery query)
protected java.util.Vector getUnmappedFields()
public java.lang.Object getValueToPutInCache(AbstractRecord row, AbstractSession session)
public int getVersionDifference(java.lang.Object currentValue, java.lang.Object domainObject, java.util.Vector primaryKeys, AbstractSession session)
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 DatabaseField getWriteLockField()
public java.lang.String getWriteLockFieldName()
public Expression getWriteLockUpdateExpression(ExpressionBuilder builder)
public java.lang.Object getWriteLockValue(java.lang.Object domainObject, java.util.Vector primaryKey, AbstractSession session)
protected java.lang.Number incrementWriteLockValue(java.lang.Number numberValue)
public void initialize(AbstractSession session)
public void initializeProperties()
public boolean isCascaded()
public boolean isChildWriteLockValueGreater(AbstractSession session, java.util.Vector primaryKey, java.lang.Class original, ObjectChangeSet changeSet)
public boolean isNewerVersion(java.lang.Object currentValue, java.lang.Object domainObject, java.util.Vector primaryKey, AbstractSession session)
public boolean isStoredInCache()
public boolean isStoredInObject()
protected java.lang.Object lockValueFromObject(java.lang.Object domainObject)
public void mergeIntoParentCache(UnitOfWorkImpl uow, java.util.Vector primaryKey, java.lang.Object object)
public void setDescriptor(ClassDescriptor descriptor)
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)
protected void updateWriteLockValueForWrite(ObjectLevelModifyQuery query, java.lang.Object lockValue)
public void setWriteLockField(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)
public void writeLockValueIntoRow(ObjectLevelModifyQuery query, java.lang.Object domainObject)
public void validateDelete(int rowCount, java.lang.Object object, DeleteObjectQuery query)
public void validateUpdate(int rowCount, java.lang.Object object, WriteObjectQuery query)
|
EclipseLink 1.0_1.0M2 API Reference - Incubation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |