Top Description Fields Constructors Methods
org.eclipse.persistence.descriptors

public Class ChangedFieldsLockingPolicy

extends FieldsLockingPolicy
Class Inheritance
Imports
java.util.*, org.eclipse.persistence.mappings.*, .DatabaseMapping.WriteType, org.eclipse.persistence.internal.helper.*, org.eclipse.persistence.internal.sessions.AbstractRecord, org.eclipse.persistence.queries.*, org.eclipse.persistence.expressions.*

Purpose: An implementation of the OptimisticLockingPolicy interface. This policy compares only the changed fields in the WHERE clause when doing an update. If any field has been changed, an optimistic locking exception will be thrown. A delete will only compare the primary key.

Note

This policy can only be used inside a unit of work.

Author
Peter Krogh
Since
TopLink 2.1

Field Summary

Inherited from org.eclipse.persistence.descriptors.FieldsLockingPolicy:
allNonPrimaryKeyFieldsdescriptor

Constructor Summary

AccessConstructor and Description
public
ChangedFieldsLockingPolicy()

PUBLIC: Create a new changed fields locking policy.

Method Summary

Modifier and TypeMethod and Description
public void
public Expression
buildDeleteExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row)

Overrides org.eclipse.persistence.descriptors.FieldsLockingPolicy.buildDeleteExpression.

Implements org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.buildDeleteExpression.

INTERNAL: When given an expression, this method will return a new expression with the optimistic locking values included.
protected List<DatabaseField>
getFieldsToCompare(DatabaseTable table, AbstractRecord transRow, AbstractRecord modifyRow)

Implements abstract org.eclipse.persistence.descriptors.FieldsLockingPolicy.getFieldsToCompare.

INTERNAL: Returns the fields that should be compared in the where clause.
Inherited from org.eclipse.persistence.descriptors.FieldsLockingPolicy:
addLockFieldsToUpdateRowbuildAllNonPrimaryKeyFieldsbuildExpressionbuildUpdateExpressionclonecompareWriteLockValuesgetAllNonPrimaryKeyFieldsgetAllNonPrimaryKeyFieldsgetBaseValuegetLockOnChangeModegetValueToPutInCachegetVersionDifferencegetWriteLockFieldgetWriteLockUpdateExpressiongetWriteLockValueinitializeinitializePropertiesisCascadedisNewerVersionisNewerVersionisPrimaryKeyisStoredInCachemergeIntoParentCachemergeIntoParentCachesetAllNonPrimaryKeyFieldssetDescriptorsetLockOnChangeModesetupWriteFieldsForInsertshouldUpdateVersionOnMappingChangeshouldUpdateVersionOnOwnedMappingChangesupportsWriteLockValuesComparisonupdateRowAndObjectForUpdatevalidateDeletevalidateUpdateverifyUsage

Constructor Detail

ChangedFieldsLockingPolicyback to summary
public ChangedFieldsLockingPolicy()

PUBLIC: Create a new changed fields locking policy. This locking policy is based on locking on all changed fields by comparing with their previous values to detect field-level collisions.

Note

the unit of work must be used for all updates when using field locking. Without a unit of work, there is no way for to know what the original values were without the back up clone in the unit of work.

Method Detail

addLockValuesToTranslationRowback to summary
public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)

Implements abstract org.eclipse.persistence.descriptors.FieldsLockingPolicy.addLockValuesToTranslationRow.

Implements org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.addLockValuesToTranslationRow.

INTERNAL: Values to be included in the locking mechanism are added to the translation row. For changed fields the normal build row is ok as only changed fields matter.

Annotations
@Override
buildDeleteExpressionback to summary
public Expression buildDeleteExpression(DatabaseTable table, Expression mainExpression, AbstractRecord row)

Overrides org.eclipse.persistence.descriptors.FieldsLockingPolicy.buildDeleteExpression.

Implements org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.buildDeleteExpression.

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. No new criteria will be added for changed fields.

Annotations
@Override
getFieldsToCompareback to summary
protected List<DatabaseField> getFieldsToCompare(DatabaseTable table, AbstractRecord transRow, AbstractRecord modifyRow)

Implements abstract org.eclipse.persistence.descriptors.FieldsLockingPolicy.getFieldsToCompare.

INTERNAL: Returns the fields that should be compared in the where clause. In this case, it is only the fields that were changed.

Annotations
@Override