Skip navigation links

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

B32476-02


oracle.toplink.descriptors
Class VersionLockingPolicy

java.lang.Object
  extended by oracle.toplink.descriptors.VersionLockingPolicy

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

public class VersionLockingPolicy
extends java.lang.Object
implements oracle.toplink.internal.descriptors.OptimisticLockingPolicy, java.io.Serializable

Purpose: Used to allow a single version number to be used for optimistic locking.

Since:
TOPLink/Java 2.0
See Also:
Serialized Form

Field Summary
static int IN_CACHE
           
static int IN_OBJECT
           

 

Constructor Summary
VersionLockingPolicy()
          Create a new VersionLockingPolicy.
VersionLockingPolicy(DatabaseField field)
          Create a new VersionLockingPolicy.
VersionLockingPolicy(java.lang.String fieldName)
          Create a new VersionLockingPolicy.

 

Method Summary
 int getVersionDifference(java.lang.Object currentValue, java.lang.Object domainObject, java.util.Vector primaryKeys, oracle.toplink.internal.sessions.AbstractSession session)
          Return the number of versions different between these objects.
 java.lang.String getWriteLockFieldName()
          Return the field name of the field that stores the write lock value.
 boolean isCascaded()
          Return true if the policy uses cascade locking.
 boolean isStoredInCache()
          Return true if the lock value is stored in the cache.
 boolean isStoredInObject()
          Return true if the lock value is stored in the object.
 void setIsCascaded(boolean isCascaded)
          Set whether to use cascade locking on the policy.
 void setIsStoredInCache(boolean isStoredInCache)
          Set whether to store the lock in the cache or in the object.
 void setWriteLockField(DatabaseField writeLockField)
          ADVANCED: Set the write lock field.
 void setWriteLockFieldName(java.lang.String writeLockFieldName)
          Set the write lock field name.
 void storeInCache()
          Configure the version lock value to be stored in the cache.
 void storeInObject()
          Configure the version lock value to be stored in the object.

 

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

 

Field Detail

IN_CACHE

public static final int IN_CACHE
See Also:
Constant Field Values

IN_OBJECT

public static final int IN_OBJECT
See Also:
Constant Field Values

Constructor Detail

VersionLockingPolicy

public VersionLockingPolicy()
Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache.

VersionLockingPolicy

public VersionLockingPolicy(java.lang.String fieldName)
Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache.
Parameters:
fieldName - specifies the field name for the write lock field.

VersionLockingPolicy

public VersionLockingPolicy(DatabaseField field)
Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache.
Parameters:
field - the write lock field.

Method Detail

getVersionDifference

public int getVersionDifference(java.lang.Object currentValue,
                                java.lang.Object domainObject,
                                java.util.Vector primaryKeys,
                                oracle.toplink.internal.sessions.AbstractSession session)
Return the number of versions different between these objects.
Specified by:
getVersionDifference in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy
Parameters:
currentValue - the new lock value
domainObject - the object containing the version to be compared to
primaryKeys - a vector containing the primary keys of the domainObject
session - the session to be used with the comparison

getWriteLockFieldName

public java.lang.String getWriteLockFieldName()
Return the field name of the field that stores the write lock value.

isCascaded

public boolean isCascaded()
Return true if the policy uses cascade locking.
Specified by:
isCascaded in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

isStoredInCache

public boolean isStoredInCache()
Return true if the lock value is stored in the cache.
Specified by:
isStoredInCache in interface oracle.toplink.internal.descriptors.OptimisticLockingPolicy

isStoredInObject

public boolean isStoredInObject()
Return true if the lock value is stored in the object.

setIsStoredInCache

public void setIsStoredInCache(boolean isStoredInCache)
Set whether to store the lock in the cache or in the object.
Parameters:
isStoredInCache - 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.

setIsCascaded

public void setIsCascaded(boolean isCascaded)
Set whether to use cascade locking on the policy.
Parameters:
isCascaded - set this to true if you would like cascade the locking and set it to false if you would like no cascade locking.

setWriteLockField

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

public void setWriteLockFieldName(java.lang.String writeLockFieldName)
Set the write lock field name.
Parameters:
writeLockFieldName - the name of the field to lock against.

storeInCache

public void storeInCache()
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

public void storeInObject()
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 TopLink and should not be updated by the application.

Skip navigation links

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