Package org.hibernate.engine.internal
Class Versioning
- java.lang.Object
-
- org.hibernate.engine.internal.Versioning
-
public final class Versioning extends Object
Utilities for dealing with optimistic locking values.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ObjectgetVersion(Object[] fields, EntityPersister persister)Extract the optimistic locking value out of the entity state snapshot.static Objectincrement(Object version, EntityVersionMapping versionMapping, SharedSessionContractImplementor session)Generate the next increment in the optimistic locking value according theVersionJavaTypecontract for the version property.static ObjectincrementVersion(Object entity, Object currentVersion, EntityPersister persister, SharedSessionContractImplementor session)Generate the next increment in the optimistic locking value according theGeneratorcontract for the version property.static booleanisNullInitialVersion(Object initialVersion)Determines if the value of the assigned version property should be considered a "null" value, that is, if it is literallynull, or if it is a negative integer.static booleanisVersionIncrementRequired(int[] dirtyProperties, boolean hasDirtyCollections, boolean[] propertyVersionability)Do we need to increment the version number, given the dirty properties?static Objectseed(EntityVersionMapping versionMapping, SharedSessionContractImplementor session)Create an initial optimistic locking value according theEntityVersionMappingcontract for the version property.static @org.hibernate.Remove booleanseedVersion(Object[] fields, int versionProperty, EntityVersionMapping versionMapping, SharedSessionContractImplementor session)static booleanseedVersion(Object entity, Object[] fields, EntityPersister persister, SharedSessionContractImplementor session)Create an initial optimistic locking value using the for the version property if required using theGeneratorcontract and inject it into the snapshot state.static voidsetVersion(Object[] fields, Object version, EntityPersister persister)Inject the optimistic locking value into the entity state snapshot.
-
-
-
Method Detail
-
seed
public static Object seed(EntityVersionMapping versionMapping, SharedSessionContractImplementor session)
Create an initial optimistic locking value according theEntityVersionMappingcontract for the version property.- Parameters:
versionMapping- The version mappingsession- The originating session- Returns:
- The initial optimistic locking value
-
seedVersion
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 theGeneratorcontract and inject it into the snapshot state.- Parameters:
fields- The current snapshot statepersister- The persister of the versioned entityentity- The entity instancesession- The originating session- Returns:
- True if we injected a new version value into the fields array; false otherwise.
-
seedVersion
@Deprecated(since="6.2") @Remove public static @org.hibernate.Remove boolean seedVersion(Object[] fields, int versionProperty, EntityVersionMapping versionMapping, SharedSessionContractImplementor session)
Create an initial optimistic locking value according theVersionJavaTypecontract for the version property if required and inject it into the snapshot state.- Parameters:
fields- The current snapshot stateversionProperty- The index of the version propertyversionMapping- The version mappingsession- The originating session- Returns:
- True if we injected a new version value into the fields array; false otherwise.
-
isNullInitialVersion
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 literallynull, or if it is a negative integer.- Parameters:
initialVersion- The value initially assigned to a version property- Returns:
- if the value shoudl be considered null for this purpose
-
incrementVersion
public static Object incrementVersion(Object entity, Object currentVersion, EntityPersister persister, SharedSessionContractImplementor session)
Generate the next increment in the optimistic locking value according theGeneratorcontract for the version property.- Parameters:
entity- The entity instancecurrentVersion- The current versionpersister- The persister of the versioned entitysession- The originating session- Returns:
- The incremented optimistic locking value.
-
increment
public static Object increment(Object version, EntityVersionMapping versionMapping, SharedSessionContractImplementor session)
Generate the next increment in the optimistic locking value according theVersionJavaTypecontract for the version property.- Parameters:
version- The current versionversionMapping- The version mappingsession- The originating session- Returns:
- The incremented optimistic locking value.
-
setVersion
public static void setVersion(Object[] fields, Object version, EntityPersister persister)
Inject the optimistic locking value into the entity state snapshot.- Parameters:
fields- The state snapshotversion- The optimistic locking valuepersister- The entity persister
-
getVersion
public static Object getVersion(Object[] fields, EntityPersister persister)
Extract the optimistic locking value out of the entity state snapshot.- Parameters:
fields- The state snapshotpersister- The entity persister- Returns:
- The extracted optimistic 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 dirtyhasDirtyCollections- 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.
-
-