Top Description Fields Constructors Methods
org.hibernate.engine.internal

public final Class Versioning

extends Object
Class Inheritance
Imports
org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.internal.CoreMessageLogger, org.hibernate.persister.entity.EntityPersister, org.hibernate.type.VersionType, org.jboss.logging.Logger

Utilities for dealing with optimistic locking values.
Author
Gavin King

Field Summary

Modifier and TypeField and Description
private static final CoreMessageLogger

Constructor Summary

AccessConstructor and Description
private
Versioning()

Private constructor disallowing instantiation.

Method Summary

Modifier and TypeMethod and Description
public static Object

Returns:

The extracted optimistic locking value
getVersion
(Object[]
The state snapshot
fields
,
EntityPersister
The entity persister
persister
)

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

public static Object

Returns:

The incremented optimistic locking value.
increment
(Object
The current version
version
,
VersionType<T>
The version type
versionType
,
SharedSessionContractImplementor
The originating session
session
)

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

public static boolean

Returns:

True if a version increment is required; false otherwise.
isVersionIncrementRequired
(final int[]
The array of property indexes which were deemed dirty
dirtyProperties
,
final boolean
Were any collections found to be dirty (structurally changed)
hasDirtyCollections
,
final boolean[]
An array indicating versionability of each property.
propertyVersionability
)

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

private static Object

Returns:

The initial optimistic locking value
seed
(VersionType<T>
The version type.
versionType
,
SharedSessionContractImplementor
The originating session
session
)

Create an initial optimistic locking value according the VersionType contract for the version property.

public static boolean

Returns:

True if we injected a new version value into the fields array; false otherwise.
seedVersion
(Object[]
The current snapshot state
fields
,
int
The index of the version property
versionProperty
,
VersionType<T>
The version type
versionType
,
SharedSessionContractImplementor
The originating session
session
)

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

public static void
setVersion(Object[]
The state snapshot
fields
,
Object
The optimistic locking value
version
,
EntityPersister
The entity persister
persister
)

Inject the optimistic locking value into the entity state snapshot.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final CoreMessageLogger LOG

Constructor Detail

Versioningback to summary
private Versioning()

Private constructor disallowing instantiation.

Method Detail

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

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

Parameters
fields:Object[]

The state snapshot

persister:EntityPersister

The entity persister

Returns:Object

The extracted optimistic locking value

incrementback to summary
public static Object increment(Object version, VersionType<T> versionType, SharedSessionContractImplementor session)

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

Parameters
version:Object

The current version

versionType:VersionType<T>

The version type

session:SharedSessionContractImplementor

The originating session

Returns:Object

The incremented optimistic locking value.

Annotations
@SuppressWarnings:unchecked
isVersionIncrementRequiredback to summary
public static boolean isVersionIncrementRequired(final int[] dirtyProperties, final boolean hasDirtyCollections, final boolean[] propertyVersionability)

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

Parameters
dirtyProperties:int[]

The array of property indexes which were deemed dirty

hasDirtyCollections:boolean

Were any collections found to be dirty (structurally changed)

propertyVersionability:boolean[]

An array indicating versionability of each property.

Returns:boolean

True if a version increment is required; false otherwise.

seedback to summary
private static Object seed(VersionType<T> versionType, SharedSessionContractImplementor session)

Create an initial optimistic locking value according the VersionType contract for the version property.

Parameters
versionType:VersionType<T>

The version type.

session:SharedSessionContractImplementor

The originating session

Returns:Object

The initial optimistic locking value

seedVersionback to summary
public static boolean seedVersion(Object[] fields, int versionProperty, VersionType<T> versionType, SharedSessionContractImplementor session)

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

Parameters
fields:Object[]

The current snapshot state

versionProperty:int

The index of the version property

versionType:VersionType<T>

The version type

session:SharedSessionContractImplementor

The originating session

Returns:boolean

True if we injected a new version value into the fields array; false otherwise.

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

Inject the optimistic locking value into the entity state snapshot.

Parameters
fields:Object[]

The state snapshot

version:Object

The optimistic locking value

persister:EntityPersister

The entity persister