Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle TopLink API Reference 10g Release 3 (10.1.3) B13698-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.toplink.descriptors
Class VersionLockingPolicy

`java.lang.Object
oracle.toplink.descriptors.VersionLockingPolicy`

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  TimestampLockingPolicy

public class VersionLockingPolicy
extends java.lang.Object
implements 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()` PUBLIC: Create a new VersionLockingPolicy.
`VersionLockingPolicy(java.lang.String fieldName)` PUBLIC: Create a new VersionLockingPolicy.

Method Summary
`int` | `getVersionDifference(java.lang.Object currentValue, java.lang.Object domainObject, java.util.Vector primaryKeys, Session session)` PUBLIC: Return the number of versions different between these objects.
`java.lang.String` | `getWriteLockFieldName()` PUBLIC: Return the field name of the field that stores the write lock value.
`boolean` | `isCascaded()` PUBLIC: Return true if the policy uses cascade locking.
`boolean` | `isStoredInCache()` PUBLIC: Return true if the lock value is stored in the cache.
`boolean` | `isStoredInObject()` PUBLIC: Return true if the lock value is stored in the object.
`void` | `setIsCascaded(boolean isCascaded)` PUBLIC: Set whether to use cascade locking on the policy.
`void` | `setIsStoredInCache(boolean isStoredInCache)` PUBLIC: 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)` PUBLIC: Set the write lock field name.
`void` | `storeInCache()` PUBLIC: Configure the version lock value to be stored in the cache.
`void` | `storeInObject()` PUBLIC: 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()

  PUBLIC: Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache.

### VersionLockingPolicy

    public VersionLockingPolicy(java.lang.String fieldName)

  PUBLIC: Create a new VersionLockingPolicy. Defaults to storing the lock value in the cache.
Parameters:
  `fieldName` - specifies the field name for the write lock field.

Method Detail

### getVersionDifference

    public int getVersionDifference(java.lang.Object currentValue,
                                    java.lang.Object domainObject,
                                    java.util.Vector primaryKeys,
                                    Session session)

  PUBLIC: Return the number of versions different between these objects.
  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()

  PUBLIC: Return the field name of the field that stores the write lock value.

### isCascaded

    public boolean isCascaded()

  PUBLIC: Return true if the policy uses cascade locking.

### isStoredInCache

    public boolean isStoredInCache()

  PUBLIC: Return true if the lock value is stored in the cache.

### isStoredInObject

    public boolean isStoredInObject()

  PUBLIC: Return true if the lock value is stored in the object.

### setIsStoredInCache

    public void setIsStoredInCache(boolean isStoredInCache)

  PUBLIC: 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)

  PUBLIC: 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)

  PUBLIC: Set the write lock field name.
  Parameters:
    `writeLockFieldName` - the name of the field to lock against.

### storeInCache

    public void storeInCache()

  PUBLIC: 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()

  PUBLIC: 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.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 1998, 2006, Oracle. All Rights Reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD