Package org.hibernate.engine.internal
Class Versioning
java.lang.Object
org.hibernate.engine.internal.Versioning
Utilities for dealing with optimistic locking values.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
getVersion
(Object[] fields, EntityPersister persister) Extract the optimistic locking value out of the entity state snapshot.static Object
increment
(Object version, EntityVersionMapping versionMapping, SharedSessionContractImplementor session) Generate the next increment in the optimistic locking value according theVersionJavaType
contract for the version property.static Object
incrementVersion
(Object entity, Object currentVersion, EntityPersister persister, SharedSessionContractImplementor session) Generate the next increment in the optimistic locking value according theGenerator
contract for the version property.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.static boolean
isVersionIncrementRequired
(int[] dirtyProperties, boolean hasDirtyCollections, boolean[] propertyVersionability) Do we need to increment the version number, given the dirty properties?static Object
seed
(EntityVersionMapping versionMapping, SharedSessionContractImplementor session) Create an initial optimistic locking value according theEntityVersionMapping
contract for the version property.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 theGenerator
contract and inject it into the snapshot state.static void
setVersion
(Object[] fields, Object version, EntityPersister persister) Inject the optimistic locking value into the entity state snapshot.
-
Method Details
-
isNullInitialVersion
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 should be considered null for this purpose
-
setVersion
Inject the optimistic locking value into the entity state snapshot.- Parameters:
fields
- The state snapshotversion
- The optimistic locking valuepersister
- The entity persister
-
getVersion
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.