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 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 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 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.