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

public final Class Versioning

extends Object
Class Inheritance
Imports
org.hibernate.Remove, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.internal.CoreMessageLogger, org.hibernate.metamodel.mapping.EntityVersionMapping, org.hibernate.persister.entity.EntityPersister, org.hibernate.type.descriptor.java.VersionJavaType, 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
,
EntityVersionMapping
The version mapping
versionMapping
,
SharedSessionContractImplementor
The originating session
session
)

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

public static Object

Returns:

The incremented optimistic locking value.
incrementVersion
(Object
The entity instance
entity
,
Object
The current version
currentVersion
,
EntityPersister
The persister of the versioned entity
persister
,
SharedSessionContractImplementor
The originating session
session
)

Generate the next increment in the optimistic locking value according the org.hibernate.generator.Generator contract for the version property.

public static boolean

Returns:

if the value shoudl be considered null for this purpose
isNullInitialVersion
(Object
The value initially assigned to a version property
initialVersion
)

Determines if the value of the assigned version property should be considered a "null" value, that is, if it is literally null, or if it is a negative integer.

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?

public static Object

Returns:

The initial optimistic locking value
seed
(EntityVersionMapping
The version mapping
versionMapping
,
SharedSessionContractImplementor
The originating session
session
)

Create an initial optimistic locking value according the EntityVersionMapping 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 entity instance
entity
,
Object[]
The current snapshot state
fields
,
EntityPersister
The persister of the versioned entity
persister
,
SharedSessionContractImplementor
The originating session
session
)

Create an initial optimistic locking value using the for the version property if required using the org.hibernate.generator.Generator contract and inject it into the snapshot state.

public static @Remove 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
,
EntityVersionMapping
The version mapping
versionMapping
,
SharedSessionContractImplementor
The originating session
session
)

Create an initial optimistic locking value according the VersionJavaType 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, EntityVersionMapping versionMapping, SharedSessionContractImplementor session)

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

Parameters
version:Object

The current version

versionMapping:EntityVersionMapping

The version mapping

session:SharedSessionContractImplementor

The originating session

Returns:Object

The incremented optimistic locking value.

incrementVersionback to summary
public static Object incrementVersion(Object entity, Object currentVersion, EntityPersister persister, SharedSessionContractImplementor session)

Generate the next increment in the optimistic locking value according the org.hibernate.generator.Generator contract for the version property.

Parameters
entity:Object

The entity instance

currentVersion:Object

The current version

persister:EntityPersister

The persister of the versioned entity

session:SharedSessionContractImplementor

The originating session

Returns:Object

The incremented optimistic locking value.

isNullInitialVersionback to summary
public static boolean isNullInitialVersion(Object initialVersion)

Determines if the value of the assigned version property should be considered a "null" value, that is, if it is literally null, or if it is a negative integer.

Parameters
initialVersion:Object

The value initially assigned to a version property

Returns:boolean

if the value shoudl be considered null for this purpose

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
public static Object seed(EntityVersionMapping versionMapping, SharedSessionContractImplementor session)

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

Parameters
versionMapping:EntityVersionMapping

The version mapping

session:SharedSessionContractImplementor

The originating session

Returns:Object

The initial optimistic locking value

seedVersionback to summary
public static boolean seedVersion(Object entity, Object[] fields, EntityPersister persister, SharedSessionContractImplementor session)

Create an initial optimistic locking value using the for the version property if required using the org.hibernate.generator.Generator contract and inject it into the snapshot state.

Parameters
entity:Object

The entity instance

fields:Object[]

The current snapshot state

persister:EntityPersister

The persister of the versioned entity

session:SharedSessionContractImplementor

The originating session

Returns:boolean

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

seedVersionback to summary
public static @Remove boolean seedVersion(Object[] fields, int versionProperty, EntityVersionMapping versionMapping, SharedSessionContractImplementor session)

Create an initial optimistic locking value according the VersionJavaType 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

versionMapping:EntityVersionMapping

The version mapping

session:SharedSessionContractImplementor

The originating session

Returns:@Remove boolean

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

Annotations
@Deprecated
since:6.2
@Remove
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