Purpose: Used to allow a single version number to be used for optimistic locking.
| Modifier and Type | Field and Description |
|---|---|
| protected transient Expression | |
| protected ClassDescriptor | |
| public static final int | |
| public static final int | |
| protected boolean | |
| protected AbstractDirectMapping | lockMapping
PERF: Cache the lock mapping if mapped with a direct mapping. |
| protected OptimisticLockingPolicy. | |
| protected int | |
| protected DatabaseField |
| Access | Constructor and Description |
|---|---|
| public | |
| public | VersionLockingPolicy(String
specifies the field name for the write
lock field. fieldName)PUBLIC: Create a new VersionLockingPolicy. |
| public | VersionLockingPolicy(DatabaseField
the write lock field. field)PUBLIC: Create a new VersionLockingPolicy. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session)
Implements org. |
| public void | addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
Implements org. |
| public Expression | buildDeleteExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row)
Implements org. |
| protected Expression | buildExpression()
INTERNAL: Returns an expression that will be used for both the update and delete where clause |
| public Expression | buildUpdateExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row, AbstractRecord row2)
Implements org. |
| public Object | clone()
Overrides java. Implements org. |
| public int | compareWriteLockValues(Object value1, Object value2)
Implements org. |
| public <T> T | getBaseValue()
Implements org. |
| protected <T> Class | getDefaultLockingFieldType()
INTERNAL: Return the default version locking filed java type, default is BigDecimal |
| protected ClassDescriptor | |
| protected <T> T | |
| public OptimisticLockingPolicy. | getLockOnChangeMode()
Implements org. |
| public <T> T | getNewLockValue(ModifyQuery query)
INTERNAL: This method gets the write lock value from either the cache or the object stored in the query. |
| protected Vector | getUnmappedFields()
INTERNAL: This method returns any of the fields that are not mapped in the object. |
| public <T> T | getValueToPutInCache(AbstractRecord row, AbstractSession session)
Implements org. |
| public int | getVersionDifference(Object
the new lock value currentValue, Object the object containing the version to be compared to domainObject, Object a vector containing the primary keys of the domainObject primaryKeys, AbstractSession the session to be used with the comparison session)Implements org. |
| public AbstractDirectMapping | getVersionMapping()
INTERNAL: Returns the mapping that will be used to access the version value from an object. |
| public DatabaseField | getWriteLockField()
Implements org. |
| public String | |
| public Expression | getWriteLockUpdateExpression(ExpressionBuilder builder, AbstractSession session)
Implements org. |
| public <T> T | getWriteLockValue(Object domainObject, Object primaryKey, AbstractSession session)
Implements org. |
| protected Number | |
| public void | initialize(AbstractSession session)
Implements org. |
| public void | initializeProperties()
Implements org. |
| public boolean | isCascaded()
Implements org. |
| public boolean | isNewerVersion(Object currentValue, Object domainObject, Object primaryKey, AbstractSession session)
Implements org. |
| public boolean | isNewerVersion(AbstractRecord databaseRow, Object domainObject, Object primaryKey, AbstractSession session)
Implements org. |
| public boolean | isNewerVersion(Object firstLockFieldValue, Object secondWriteLockFieldValue)
INTERNAL: Compares two values. |
| public boolean | isStoredInCache()
Implements org. |
| public boolean | |
| protected Object | |
| public void | mergeIntoParentCache(UnitOfWorkImpl uow, Object primaryKey, Object object)
Implements org. |
| public void | mergeIntoParentCache(CacheKey unitOfWorkCacheKey, CacheKey parentSessionCacheKey)
Implements org. |
| public void | setDescriptor(ClassDescriptor descriptor)
Implements org. |
| public void | setIsCascaded(boolean
set this to true if you would like cascade the locking
and set it to false if you would like no cascade locking. isCascaded)PUBLIC: Set whether to use cascade locking on the policy. |
| public void | setIsStoredInCache(boolean
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. isStoredInCache)PUBLIC: Set whether to store the lock in the cache or in the object. |
| public void | setLockOnChangeMode(OptimisticLockingPolicy.
Implements org. |
| public void | setupWriteFieldsForInsert(ObjectLevelModifyQuery query)
Implements org. |
| public void | |
| public void | setWriteLockFieldName(String
the name of the field to lock against. writeLockFieldName)PUBLIC: Set the write lock field name. |
| public boolean | shouldUpdateVersionOnMappingChange()
Implements org. |
| public boolean | shouldUpdateVersionOnOwnedMappingChange()
Implements org. |
| public void | |
| public void | |
| public boolean | supportsWriteLockValuesComparison()
Implements org. |
| public void | |
| public void | updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object domainObject)
Implements org. |
| protected void | updateWriteLockValueForWrite(ObjectLevelModifyQuery query, Object lockValue)
INTERNAL: Update the row, object and change set with the version value. |
| public void | validateDelete(int rowCount, Object object, DeleteObjectQuery query)
Implements org. |
| public void | validateUpdate(int rowCount, Object object, WriteObjectQuery query)
Implements org. |
| public void | writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject)
INTERNAL: This method updates the modify row with the old lock value. |
| cachedExpression | back to summary |
|---|---|
| protected transient Expression cachedExpression | |
| descriptor | back to summary |
|---|---|
| protected ClassDescriptor descriptor | |
| IN_CACHE | back to summary |
|---|---|
| public static final int IN_CACHE | |
| IN_OBJECT | back to summary |
|---|---|
| public static final int IN_OBJECT | |
| isCascaded | back to summary |
|---|---|
| protected boolean isCascaded | |
| lockMapping | back to summary |
|---|---|
| protected AbstractDirectMapping lockMapping PERF: Cache the lock mapping if mapped with a direct mapping. | |
| lockOnChangeMode | back to summary |
|---|---|
| protected OptimisticLockingPolicy. | |
| lockValueStored | back to summary |
|---|---|
| protected int lockValueStored | |
| writeLockField | back to summary |
|---|---|
| protected DatabaseField writeLockField | |
| VersionLockingPolicy | back to summary |
|---|---|
| public VersionLockingPolicy() PUBLIC: Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache. | |
| VersionLockingPolicy | back to summary |
|---|---|
| public VersionLockingPolicy(String fieldName) PUBLIC: Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache.
| |
| VersionLockingPolicy | back to summary |
|---|---|
| public VersionLockingPolicy(DatabaseField field) PUBLIC: Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache.
| |
| addLockFieldsToUpdateRow | back to summary |
|---|---|
| public void addLockFieldsToUpdateRow(AbstractRecord databaseRow, AbstractSession session) Implements org. INTERNAL: Add update fields for template row. These are any unmapped fields required to write in an update.
| |
| addLockValuesToTranslationRow | back to summary |
|---|---|
| public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query) Implements org. 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.
| |
| buildDeleteExpression | back to summary |
|---|---|
| public Expression buildDeleteExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row) Implements org. INTERNAL: When given an expression, this method will return a new expression with the optimistic locking values included. The values are taken from the passed in database row. This expression will be used in a delete call.
| |
| buildExpression | back to summary |
|---|---|
| protected Expression buildExpression() INTERNAL: Returns an expression that will be used for both the update and delete where clause | |
| buildUpdateExpression | back to summary |
|---|---|
| public Expression buildUpdateExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row, AbstractRecord row2) Implements org. INTERNAL: When given an expression, this method will return a new expression with the optimistic locking values included. The values are taken from the passed in database row. This expression will be used in an update call.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Implements org. INTERNAL: Clone the policy
| |
| compareWriteLockValues | back to summary |
|---|---|
| public int compareWriteLockValues(Object value1, Object value2) Implements org. INTERNAL: This method compares two writeLockValues. The writeLockValues should be non-null and of type Number. 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.
| |
| getBaseValue | back to summary |
|---|---|
| public <T> T getBaseValue() Implements org. INTERNAL: This is the base value that is older than all other values, it is used in the place of null in some situations.
| |
| getDefaultLockingFieldType | back to summary |
|---|---|
| protected <T> Class INTERNAL: Return the default version locking filed java type, default is BigDecimal
| |
| getDescriptor | back to summary |
|---|---|
| protected ClassDescriptor getDescriptor() INTERNAL: | |
| getInitialWriteValue | back to summary |
|---|---|
| protected <T> T getInitialWriteValue(AbstractSession session) INTERNAL: returns the initial locking value
| |
| getLockOnChangeMode | back to summary |
|---|---|
| public OptimisticLockingPolicy. Implements org. 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. Unfortunately this locking policy can not enforce an optimistic write lock unless a FK or DTF field has changed so this type returns LockOnChange.NONE
| |
| getNewLockValue | back to summary |
|---|---|
| public <T> T getNewLockValue(ModifyQuery query) INTERNAL: This method gets the write lock value from either the cache or the object stored in the query. It then returns the new incremented value.
| |
| getUnmappedFields | back to summary |
|---|---|
| protected Vector INTERNAL: This method returns any of the fields that are not mapped in the object. In the case of the value being stored in the cache, a vector with one value is returned. In the case of being stored in the object, an empty vector is returned. | |
| getValueToPutInCache | back to summary |
|---|---|
| public <T> T getValueToPutInCache(AbstractRecord row, AbstractSession session) Implements org. INTERNAL: Return the value that should be stored in the identity map. If the value is stored in the object, then return a null.
| |
| getVersionDifference | back to summary |
|---|---|
| public int getVersionDifference(Object currentValue, Object domainObject, Object primaryKeys, AbstractSession session) Implements org. PUBLIC: Return the number of versions different between these objects.
| |
| getVersionMapping | back to summary |
|---|---|
| public AbstractDirectMapping getVersionMapping() INTERNAL: Returns the mapping that will be used to access the version value from an object. | |
| getWriteLockField | back to summary |
|---|---|
| public DatabaseField getWriteLockField() Implements org. INTERNAL: Return the write lock field.
| |
| getWriteLockFieldName | back to summary |
|---|---|
| public String getWriteLockFieldName() PUBLIC: Return the field name of the field that stores the write lock value. | |
| getWriteLockUpdateExpression | back to summary |
|---|---|
| public Expression getWriteLockUpdateExpression(ExpressionBuilder builder, AbstractSession session) Implements org. INTERNAL: Retrun an expression that updates the write lock
| |
| getWriteLockValue | back to summary |
|---|---|
| public <T> T getWriteLockValue(Object domainObject, Object primaryKey, AbstractSession session) Implements org. INTERNAL: This method will return the optimistic lock value for the object
| |
| incrementWriteLockValue | back to summary |
|---|---|
| protected Number incrementWriteLockValue(Number numberValue) INTERNAL: Adds 1 to the value passed in. | |
| initialize | back to summary |
|---|---|
| public void initialize(AbstractSession session) Implements org. INTERNAL: It is responsible for initializing the policy;
| |
| initializeProperties | back to summary |
|---|---|
| public void initializeProperties() Implements org. INTERNAL: It is responsible for initializing the policy properties;
| |
| isCascaded | back to summary |
|---|---|
| public boolean isCascaded() Implements org. PUBLIC: Return true if the policy uses cascade locking.
| |
| isNewerVersion | back to summary |
|---|---|
| public boolean isNewerVersion(Object currentValue, Object domainObject, Object primaryKey, AbstractSession session) Implements org. INTERNAL: Compares the value with the value from the object (or cache). Will return true if the currentValue is newer than the domainObject.
| |
| isNewerVersion | back to summary |
|---|---|
| public boolean isNewerVersion(AbstractRecord databaseRow, Object domainObject, Object primaryKey, AbstractSession session) Implements org. INTERNAL: Compares the value from the row and from the object (or cache). Will return true if the row is newer than the object.
| |
| isNewerVersion | back to summary |
|---|---|
| public boolean isNewerVersion(Object firstLockFieldValue, Object secondWriteLockFieldValue) INTERNAL: Compares two values. Will return true if the firstLockFieldValue is newer than the secondWriteLockFieldValue. | |
| isStoredInCache | back to summary |
|---|---|
| public boolean isStoredInCache() Implements org. PUBLIC: Return true if the lock value is stored in the cache.
| |
| isStoredInObject | back to summary |
|---|---|
| public boolean isStoredInObject() PUBLIC: Return true if the lock value is stored in the object. | |
| lockValueFromObject | back to summary |
|---|---|
| protected Object lockValueFromObject(Object domainObject) INTERNAL: Retrieves the lock value from the object. | |
| mergeIntoParentCache | back to summary |
|---|---|
| public void mergeIntoParentCache(UnitOfWorkImpl uow, Object primaryKey, Object object) Implements org. INTERNAL: Only applicable when the value is stored in the cache. Will merge with the parent unit of work.
| |
| mergeIntoParentCache | back to summary |
|---|---|
| public void mergeIntoParentCache(CacheKey unitOfWorkCacheKey, CacheKey parentSessionCacheKey) Implements org. INTERNAL: This method should merge changes from the parent into the child. #see this method in VersionLockingPolicy
| |
| setDescriptor | back to summary |
|---|---|
| public void setDescriptor(ClassDescriptor descriptor) Implements org. INTERNAL:
| |
| setIsCascaded | back to summary |
|---|---|
| public void setIsCascaded(boolean isCascaded) PUBLIC: Set whether to use cascade locking on the policy.
| |
| setIsStoredInCache | back to summary |
|---|---|
| public void setIsStoredInCache(boolean isStoredInCache) PUBLIC: Set whether to store the lock in the cache or in the object.
| |
| setLockOnChangeMode | back to summary |
|---|---|
| public void setLockOnChangeMode(OptimisticLockingPolicy. Implements org. 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.
| |
| setupWriteFieldsForInsert | back to summary |
|---|---|
| public void setupWriteFieldsForInsert(ObjectLevelModifyQuery query) Implements org. INTERNAL: This method must be included in any locking policy. Put the initial writelock value into the modifyRow.
| |
| setWriteLockField | back to summary |
|---|---|
| public void setWriteLockField(DatabaseField writeLockField) ADVANCED: Set the write lock field. This can be used for advanced field types, such as XML nodes, or to set the field type. | |
| setWriteLockFieldName | back to summary |
|---|---|
| public void setWriteLockFieldName(String writeLockFieldName) PUBLIC: Set the write lock field name.
| |
| shouldUpdateVersionOnMappingChange | back to summary |
|---|---|
| public boolean shouldUpdateVersionOnMappingChange() Implements org. INTERNAL: Returns true if the policy has been set to set an optimistic read lock when any mapping changes.
| |
| shouldUpdateVersionOnOwnedMappingChange | back to summary |
|---|---|
| public boolean shouldUpdateVersionOnOwnedMappingChange() Implements org. INTERNAL: Returns true if the policy has been set to set an optimistic read lock when a owning mapping changes.
| |
| storeInCache | back to summary |
|---|---|
| public void storeInCache() PUBLIC: Configure the version lock value to be stored in the cache. This allows for the object not to require to store its version value as an attribute. Note if using a stateless model where the object can be passed to a client and then later updated in a different transaction context, then the version lock value should not be stored in the cache, but in the object to ensure it is the correct value for that object. This is the default. | |
| storeInObject | back to summary |
|---|---|
| public void storeInObject() PUBLIC: Configure the version lock value to be stored in the object. The object must define a mapping and an attribute to store the version value. Note the value will be updated internally by EclipseLink and should not be updated by the application. | |
| supportsWriteLockValuesComparison | back to summary |
|---|---|
| public boolean supportsWriteLockValuesComparison() Implements org. INTERNAL: Indicates that compareWriteLockValues method is supported by the policy.
| |
| updateObjectWithWriteValue | back to summary |
|---|---|
| public void updateObjectWithWriteValue(ObjectLevelModifyQuery query, Object lockValue) | |
| updateRowAndObjectForUpdate | back to summary |
|---|---|
| public void updateRowAndObjectForUpdate(ObjectLevelModifyQuery query, Object domainObject) Implements org. INTERNAL: This method updates the modify row, and the domain object with the new lock value.
| |
| updateWriteLockValueForWrite | back to summary |
|---|---|
| protected void updateWriteLockValueForWrite(ObjectLevelModifyQuery query, Object lockValue) INTERNAL: Update the row, object and change set with the version value. This handles the version being mapped in nested aggregates, writable or read-only. | |
| validateDelete | back to summary |
|---|---|
| public void validateDelete(int rowCount, Object object, DeleteObjectQuery query) Implements org. INTERNAL: Check the row count for lock failure.
| |
| validateUpdate | back to summary |
|---|---|
| public void validateUpdate(int rowCount, Object object, WriteObjectQuery query) Implements org. INTERNAL: Check the row count for lock failure.
| |
| writeLockValueIntoRow | back to summary |
|---|---|
| public void writeLockValueIntoRow(ObjectLevelModifyQuery query, Object domainObject) INTERNAL: This method updates the modify row with the old lock value. | |