Oracle Application Server TopLink API Reference
10g (9.0.4.3)

B10491-02

oracle.toplink.descriptors
Class FieldsLockingPolicy

java.lang.Object
  extended byoracle.toplink.descriptors.FieldsLockingPolicy

All Implemented Interfaces:
java.lang.Cloneable, oracle.toplink.internal.descriptors.OptimisticLockingPolicy, java.io.Serializable
Direct Known Subclasses:
AllFieldsLockingPolicy, ChangedFieldsLockingPolicy, SelectedFieldsLockingPolicy

public abstract class FieldsLockingPolicy
extends java.lang.Object
implements oracle.toplink.internal.descriptors.OptimisticLockingPolicy

Purpose: An abstract superclass of some implementations of the OptimisticLockingPolicy interface. All of the subclasses of this class implement OptimisticLocking based on mapped fields in the object. These fields are only compared and not modified. Any modification (incrementing etc..) must be handled by the application.

Since:
TopLink 2.1
See Also:
AllFieldsLockingPolicy, ChangedFieldsLockingPolicy, SelectedFieldsLockingPolicy, Serialized Form

Constructor Summary
FieldsLockingPolicy()
          PUBLIC: Create a new field locking policy.

 

Method Summary
 void addLockFieldsToUpdateRow(DatabaseRow databaseRow, oracle.toplink.publicinterface.Session session)
          INTERNAL: Add update fields for template row.
abstract  void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
          INTERNAL: Values to be included in the locking mechanism are added to the translation row.
 Expression buildDeleteExpression(oracle.toplink.internal.helper.DatabaseTable table, Expression mainExpression, DatabaseRow row)
          INTERNAL: When given an expression, this method will return a new expression with the optimistic locking values included.
 Expression buildUpdateExpression(oracle.toplink.internal.helper.DatabaseTable table, Expression mainExpression, DatabaseRow transRow, DatabaseRow modifyRow)
          INTERNAL: This method must be included in any locking policy.
 java.lang.Object clone()
          INTERNAL: Clone the policy
 java.lang.Object getValueToPutInCache(DatabaseRow row, oracle.toplink.publicinterface.Session 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, oracle.toplink.publicinterface.Session session)
          INTERNAL: Return the number of version difference between the two states of the object.
 java.lang.Object getWriteLockValue(java.lang.Object domainObject, java.util.Vector primaryKey, oracle.toplink.publicinterface.Session session)
          INTERNAL: This method will return the optimistic lock value for the object
 void initialize(oracle.toplink.publicinterface.Session session)
          INTERNAL: It is responsible for initializing the policy;
 void initializeProperties()
          INTERNAL: It is responsible for initializing the policy;
 boolean isChildWriteLockValueGreater(oracle.toplink.publicinterface.Session session, java.util.Vector primaryKey, java.lang.Class original, oracle.toplink.internal.sessions.ObjectChangeSet changeSet)
          INTERNAL:
 boolean isChildWriteLockValueGreater(oracle.toplink.publicinterface.UnitOfWork uow, java.util.Vector primaryKey, java.lang.Class original)
          INTERNAL:
 boolean isNewerVersion(DatabaseRow databaseRow, java.lang.Object domainObject, java.util.Vector primaryKey, oracle.toplink.publicinterface.Session session)
          INTERNAL: Compares the value from the row and from the object (or cache).
 boolean isNewerVersion(java.lang.Object currentValue, java.lang.Object domainObject, java.util.Vector primaryKey, oracle.toplink.publicinterface.Session session)
          INTERNAL: Compares the value and the value from the object (or cache).
 void mergeIntoParentCache(oracle.toplink.publicinterface.UnitOfWork uow, java.util.Vector primaryKey, java.lang.Object object)
          INTERNAL: Only applicable when the value is stored in the cache.
 void registerObjectIntoParentCache(oracle.toplink.publicinterface.UnitOfWork uow, java.util.Vector primaryKey, java.lang.Object original)
          INTERNAL: Update the parent write lock value if the unit of works has been incremented.
 void setDescriptor(Descriptor descriptor)
          INTERNAL: Set method for the descriptor
 void setupWriteFieldsForInsert(ModifyQuery query)
          INTERNAL: Put the initial writelock value into the modifyRow.
 void updateRowAndObjectForUpdate(ModifyQuery query, java.lang.Object domainObject)
          INTERNAL: Nothing to do because all updates are handled by the application
 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.

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

FieldsLockingPolicy

public FieldsLockingPolicy()
PUBLIC: Create a new field locking policy. A field locking policy is based on locking on a subset of 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

addLockFieldsToUpdateRow

public void addLockFieldsToUpdateRow(DatabaseRow databaseRow,
                                     oracle.toplink.publicinterface.Session session)
INTERNAL: Add update fields for template row. These are any unmapped fields required to write in an update. Since all fields are mapped, there is nothing required.
Specified by:
addLockFieldsToUpdateRow in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

addLockValuesToTranslationRow

public abstract void addLockValuesToTranslationRow(ObjectLevelModifyQuery query)
INTERNAL: Values to be included in the locking mechanism are added to the translation row. Set the translation row to all the original field values.
Specified by:
addLockValuesToTranslationRow in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

buildDeleteExpression

public Expression buildDeleteExpression(oracle.toplink.internal.helper.DatabaseTable table,
Expression mainExpression,
DatabaseRow 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.
Specified by:
buildDeleteExpression in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

buildUpdateExpression

public Expression buildUpdateExpression(oracle.toplink.internal.helper.DatabaseTable table,
Expression mainExpression,
DatabaseRow transRow,
DatabaseRow modifyRow)
INTERNAL: This method must be included in any locking policy. 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.
Specified by:
buildUpdateExpression in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

clone

public java.lang.Object clone()
INTERNAL: Clone the policy
Specified by:
clone in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

getValueToPutInCache

public java.lang.Object getValueToPutInCache(DatabaseRow row,
                                             oracle.toplink.publicinterface.Session session)
INTERNAL: Return the value that should be stored in the identity map. If the value is stored in the object, then return a null.
Specified by:
getValueToPutInCache in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

getVersionDifference

public int getVersionDifference(java.lang.Object currentValue,
                                java.lang.Object domainObject,
                                java.util.Vector primaryKeys,
                                oracle.toplink.publicinterface.Session session)
INTERNAL: Return the number of version difference between the two states of the object.
Specified by:
getVersionDifference in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

getWriteLockValue

public java.lang.Object getWriteLockValue(java.lang.Object domainObject,
                                          java.util.Vector primaryKey,
                                          oracle.toplink.publicinterface.Session session)
INTERNAL: This method will return the optimistic lock value for the object
Specified by:
getWriteLockValue in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

initialize

public void initialize(oracle.toplink.publicinterface.Session session)
INTERNAL: It is responsible for initializing the policy;
Specified by:
initialize in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

initializeProperties

public void initializeProperties()
INTERNAL: It is responsible for initializing the policy;
Specified by:
initializeProperties in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

isChildWriteLockValueGreater

public boolean isChildWriteLockValueGreater(oracle.toplink.publicinterface.Session session,
                                            java.util.Vector primaryKey,
                                            java.lang.Class original,
                                            oracle.toplink.internal.sessions.ObjectChangeSet changeSet)
INTERNAL:
Specified by:
isChildWriteLockValueGreater in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

isChildWriteLockValueGreater

public boolean isChildWriteLockValueGreater(oracle.toplink.publicinterface.UnitOfWork uow,
                                            java.util.Vector primaryKey,
                                            java.lang.Class original)
INTERNAL:
Specified by:
isChildWriteLockValueGreater in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

isNewerVersion

public boolean isNewerVersion(java.lang.Object currentValue,
                              java.lang.Object domainObject,
                              java.util.Vector primaryKey,
                              oracle.toplink.publicinterface.Session session)
INTERNAL: Compares the value and the value from the object (or cache). Will return true if the object is newer than the row.
Specified by:
isNewerVersion in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

isNewerVersion

public boolean isNewerVersion(DatabaseRow databaseRow,
                              java.lang.Object domainObject,
                              java.util.Vector primaryKey,
                              oracle.toplink.publicinterface.Session session)
INTERNAL: Compares the value from the row and from the object (or cache). Will return true if the object is newer than the row.
Specified by:
isNewerVersion in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

mergeIntoParentCache

public void mergeIntoParentCache(oracle.toplink.publicinterface.UnitOfWork uow,
                                 java.util.Vector primaryKey,
                                 java.lang.Object object)
INTERNAL: Only applicable when the value is stored in the cache.
Specified by:
mergeIntoParentCache in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

registerObjectIntoParentCache

public void registerObjectIntoParentCache(oracle.toplink.publicinterface.UnitOfWork uow,
                                          java.util.Vector primaryKey,
                                          java.lang.Object original)
INTERNAL: Update the parent write lock value if the unit of works has been incremented. Nothing to do here because the value is always stored in the object.

setDescriptor

public void setDescriptor(Descriptor descriptor)
INTERNAL: Set method for the descriptor
Specified by:
setDescriptor in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

setupWriteFieldsForInsert

public void setupWriteFieldsForInsert(ModifyQuery query)
INTERNAL: Put the initial writelock value into the modifyRow. There is nothing to do because all the lock values are in the mappings.
Specified by:
setupWriteFieldsForInsert in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

updateRowAndObjectForUpdate

public void updateRowAndObjectForUpdate(ModifyQuery query,
                                        java.lang.Object domainObject)
INTERNAL: Nothing to do because all updates are handled by the application
Specified by:
updateRowAndObjectForUpdate in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

validateDelete

public void validateDelete(int rowCount,
                           java.lang.Object object,
DeleteObjectQuery query)
INTERNAL: Check the row count for lock failure.
Specified by:
validateDelete in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

validateUpdate

public void validateUpdate(int rowCount,
                           java.lang.Object object,
WriteObjectQuery query)
INTERNAL: Check the row count for lock failure.
Specified by:
validateUpdate in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

Copyright © 1998, 2004 Oracle Corporation. All Rights Reserved.