EclipseLink 2.2.0, build 'v20110202-r8913' API Reference

org.eclipse.persistence.descriptors
Class ChangedFieldsLockingPolicy

java.lang.Object
  extended by org.eclipse.persistence.descriptors.FieldsLockingPolicy
      extended by org.eclipse.persistence.descriptors.ChangedFieldsLockingPolicy
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy

public class ChangedFieldsLockingPolicy
extends FieldsLockingPolicy

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.

See Also:
Serialized Form
Author:
Peter Krogh
Since:
TopLink 2.1

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy.LockOnChange
 
Field Summary
 
Fields inherited from class org.eclipse.persistence.descriptors.FieldsLockingPolicy
allNonPrimaryKeyFields, descriptor
 
Constructor Summary
ChangedFieldsLockingPolicy()
          PUBLIC: Create a new changed fields locking policy.
 
Method Summary
 void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
          INTERNAL: Values to be included in the locking mechanism are added to the translation row.
 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  java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getFieldsToCompare(org.eclipse.persistence.internal.helper.DatabaseTable table, org.eclipse.persistence.internal.sessions.AbstractRecord transRow, org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow)
          INTERNAL: Returns the fields that should be compared in the where clause.
 
Methods inherited from class org.eclipse.persistence.descriptors.FieldsLockingPolicy
addLockFieldsToUpdateRow, buildAllNonPrimaryKeyFields, buildExpression, buildUpdateExpression, clone, compareWriteLockValues, getAllNonPrimaryKeyFields, getAllNonPrimaryKeyFields, getBaseValue, getLockOnChangeMode, getValueToPutInCache, getVersionDifference, getWriteLockField, getWriteLockUpdateExpression, getWriteLockValue, initialize, initializeProperties, isCascaded, isNewerVersion, isNewerVersion, isPrimaryKey, isStoredInCache, mergeIntoParentCache, setAllNonPrimaryKeyFields, setDescriptor, setLockOnChangeMode, setupWriteFieldsForInsert, shouldUpdateVersionOnMappingChange, shouldUpdateVersionOnOwnedMappingChange, supportsWriteLockValuesComparison, updateRowAndObjectForUpdate, validateDelete, validateUpdate, verifyUsage
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangedFieldsLockingPolicy

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

addLockValuesToTranslationRow

public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
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.

Specified by:
addLockValuesToTranslationRow in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
Specified by:
addLockValuesToTranslationRow in class FieldsLockingPolicy

buildDeleteExpression

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

Specified by:
buildDeleteExpression in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
Overrides:
buildDeleteExpression in class FieldsLockingPolicy

getFieldsToCompare

protected java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> getFieldsToCompare(org.eclipse.persistence.internal.helper.DatabaseTable table,
                                                                                                   org.eclipse.persistence.internal.sessions.AbstractRecord transRow,
                                                                                                   org.eclipse.persistence.internal.sessions.AbstractRecord modifyRow)
INTERNAL: Returns the fields that should be compared in the where clause. In this case, it is only the fields that were changed.

Specified by:
getFieldsToCompare in class FieldsLockingPolicy

EclipseLink 2.2.0, build 'v20110202-r8913' API Reference