Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


org.eclipse.persistence.descriptors
Class SelectedFieldsLockingPolicy

java.lang.Object
  extended by org.eclipse.persistence.descriptors.FieldsLockingPolicy
      extended by org.eclipse.persistence.descriptors.SelectedFieldsLockingPolicy

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy

public class SelectedFieldsLockingPolicy
extends FieldsLockingPolicy

Purpose: An implementation of the OptimisticLockingPolicy interface. This policy compares selected fields in the WHERE clause when doing an update or a delete. If any field has been changed, an optimistic locking exception will be thrown. Note that the fields specified must be mapped and not be primary keys.

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

Since:
TopLink 2.5
See Also:
Serialized Form

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  java.util.Vector lockFields
           
protected  java.util.Map lockFieldsByTable
           

 

Fields inherited from class org.eclipse.persistence.descriptors.FieldsLockingPolicy
allNonPrimaryKeyFields, descriptor

 

Constructor Summary
SelectedFieldsLockingPolicy()
          PUBLIC: Create a new selected fields locking policy.

 

Method Summary
 void addLockFieldName(java.lang.String fieldName)
          PUBLIC: Add a fieldname to lock on.
 void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
          INTERNAL: Values to be included in the locking mechanism are added to the translation row.
protected  java.util.Vector 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 lock fields to compare based on the passed in table.
 java.util.Vector getLockFields()
          INTERNAL: Returns the lock fields
protected  java.util.Vector getLockFields(org.eclipse.persistence.internal.helper.DatabaseTable table)
          INTERNAL: returns the lock fields based on the passed in table
protected  java.util.Map getLockFieldsByTable()
          INTERNAL: returns the lock fields
 void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: It is responsible for initializing the policy;
 void setLockFieldNames(java.util.Vector lockFieldNames)
          PUBLIC: Set the field names to lock on.
 void setLockFields(java.util.Map lockFieldsByTable)
          INTERNAL: Used to set the field names to be used in this policy.
protected  void setLockFields(java.util.Vector lockFields)
          INTERNAL: Sets the lock fields
protected  void setLockFieldsByTable(java.util.Map lockFieldsByTable)
          INTERNAL: Used to set the field names to be used in this policy.

 

Methods inherited from class org.eclipse.persistence.descriptors.FieldsLockingPolicy
addLockFieldsToUpdateRow, buildAllNonPrimaryKeyFields, buildDeleteExpression, buildExpression, buildUpdateExpression, clone, compareWriteLockValues, getAllNonPrimaryKeyFields, getAllNonPrimaryKeyFields, getBaseValue, getLockOnChangeMode, getValueToPutInCache, getVersionDifference, getWriteLockField, getWriteLockUpdateExpression, getWriteLockValue, 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

 

Field Detail

lockFieldsByTable

protected java.util.Map lockFieldsByTable

lockFields

protected java.util.Vector lockFields

Constructor Detail

SelectedFieldsLockingPolicy

public SelectedFieldsLockingPolicy()
PUBLIC: Create a new selected fields locking policy. A field locking policy is based on locking on the specified 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.

Method Detail

addLockFieldName

public void addLockFieldName(java.lang.String fieldName)
PUBLIC: Add a fieldname to lock on. All fields in this list will be compared when Updating if the value of any of the fields does not match the value in memory, an OptimisticLockException will be thrown. Note: An Automatic update will not be done on this field, only a comparison occurs.

addLockValuesToTranslationRow

public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
                                   throws DatabaseException
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
Throws:
DatabaseException

getFieldsToCompare

protected java.util.Vector 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 lock fields to compare based on the passed in table.
Specified by:
getFieldsToCompare in class FieldsLockingPolicy

getLockFields

public java.util.Vector getLockFields()
INTERNAL: Returns the lock fields

getLockFields

protected java.util.Vector getLockFields(org.eclipse.persistence.internal.helper.DatabaseTable table)
INTERNAL: returns the lock fields based on the passed in table

getLockFieldsByTable

protected java.util.Map getLockFieldsByTable()
INTERNAL: returns the lock fields

initialize

public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: It is responsible for initializing the policy;
Specified by:
initialize in interface org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy
Overrides:
initialize in class FieldsLockingPolicy

setLockFieldNames

public void setLockFieldNames(java.util.Vector lockFieldNames)
PUBLIC: Set the field names to lock on. All fields in this list will be compared when Updating. If the value of any of the fields does not match the value in memory, an OptimisticLockException will be thrown. Note: An Automatic update will not be done on this field, only a comparison occurs.

setLockFields

public void setLockFields(java.util.Map lockFieldsByTable)
INTERNAL: Used to set the field names to be used in this policy.

setLockFields

protected void setLockFields(java.util.Vector lockFields)
INTERNAL: Sets the lock fields

setLockFieldsByTable

protected void setLockFieldsByTable(java.util.Map lockFieldsByTable)
INTERNAL: Used to set the field names to be used in this policy.

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.