Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hibernate.engine
Class Versioning

    java.lang.Object
      org.hibernate.engine.Versioning

    public final class Versioning

extends Object

Utilities for dealing with optimisitic locking values.

Author:
  Gavin King

Field Summary
`static int` | `OPTIMISTIC_LOCK_ALL` Apply optimisitc locking based on the a current vs.
`static int` | `OPTIMISTIC_LOCK_DIRTY` Apply optimisitc locking based on the a current vs.
`static int` | `OPTIMISTIC_LOCK_NONE` Apply no optimistic locking
`static int` | `OPTIMISTIC_LOCK_VERSION` Apply optimisitc locking based on the defined version or timestamp property.

Method Summary
`static Object` | `getVersion(Object[] fields, EntityPersister persister)` Extract the optimisitc locking value out of the entity state snapshot.
`static Object` | `increment(Object version, VersionType versionType, SessionImplementor session)` Generate the next increment in the optimisitc locking value according the `VersionType` contract for the version property.
`static boolean` | `isVersionIncrementRequired(int[] dirtyProperties, boolean hasDirtyCollections, boolean[] propertyVersionability)` Do we need to increment the version number, given the dirty properties?
`static boolean` | `seedVersion(Object[] fields, int versionProperty, VersionType versionType, SessionImplementor session)` Create an initial optimisitc locking value according the `VersionType` contract for the version property if required and inject it into the snapshot state.
`static void` | `setVersion(Object[] fields, Object version, EntityPersister persister)` Inject the optimisitc locking value into the entity state snapshot.

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

Field Detail

### OPTIMISTIC_LOCK_NONE

    public static final int OPTIMISTIC_LOCK_NONE

  Apply no optimistic locking

  See Also:
    Constant Field Values

### OPTIMISTIC_LOCK_VERSION

    public static final int OPTIMISTIC_LOCK_VERSION

  Apply optimisitc locking based on the defined version or timestamp property.

  See Also:
    Constant Field Values

### OPTIMISTIC_LOCK_ALL

    public static final int OPTIMISTIC_LOCK_ALL

  Apply optimisitc locking based on the a current vs. snapshot comparison of all properties.

  See Also:
    Constant Field Values

### OPTIMISTIC_LOCK_DIRTY

    public static final int OPTIMISTIC_LOCK_DIRTY

  Apply optimisitc locking based on the a current vs. snapshot comparison of dirty properties.

  See Also:
    Constant Field Values

Method Detail

### seedVersion

    public static boolean seedVersion(Object[] fields,
                                      int versionProperty,
                                      VersionType versionType,
                                      SessionImplementor session)

  Create an initial optimisitc locking value according the `VersionType` contract for the version property if required and inject it into the snapshot state.

  Parameters:
    `fields` - The current snapshot state
    `versionProperty` - The index of the version property
    `versionType` - The version type
    `session` - The orginating session
  Returns:
    True if we injected a new version value into the fields array; false otherwise.

### increment

    public static Object increment(Object version,
                                   VersionType versionType,
                                   SessionImplementor session)

  Generate the next increment in the optimisitc locking value according the `VersionType` contract for the version property.

  Parameters:
    `version` - The current version
    `versionType` - The version type
    `session` - The originating session
  Returns:
    The incremented optimistic locking value.

### setVersion

    public static void setVersion(Object[] fields,
                                  Object version,
                                  EntityPersister persister)

  Inject the optimisitc locking value into the entity state snapshot.

  Parameters:
    `fields` - The state snapshot
    `version` - The optimisitc locking value
    `persister` - The entity persister

### getVersion

    public static Object getVersion(Object[] fields,
                                    EntityPersister persister)

  Extract the optimisitc locking value out of the entity state snapshot.

  Parameters:
    `fields` - The state snapshot
    `persister` - The entity persister
  Returns:
    The extracted optimisitc locking value

### isVersionIncrementRequired

    public static boolean isVersionIncrementRequired(int[] dirtyProperties,
                                                     boolean hasDirtyCollections,
                                                     boolean[] propertyVersionability)

  Do we need to increment the version number, given the dirty properties?

  Parameters:
    `dirtyProperties` - The array of property indexes which were deemed dirty
    `hasDirtyCollections` - Were any collections found to be dirty (structurally changed)
    `propertyVersionability` - An array indicating versionability of each property.
  Returns:
    True if a version increment is required; false otherwise.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD