类 Versioning


  • public final class Versioning
    extends Object
    Utilities for dealing with optimistic locking values.
    作者:
    Gavin King
    • 方法详细资料

      • seedVersion

        public static boolean seedVersion​(Object[] fields,
                                          int versionProperty,
                                          VersionType 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.
        参数:
        fields - The current snapshot state
        versionProperty - The index of the version property
        versionType - The version type
        session - The originating session
        返回:
        True if we injected a new version value into the fields array; false otherwise.
      • increment

        public static Object increment​(Object version,
                                       VersionType versionType,
                                       SharedSessionContractImplementor session)
        Generate the next increment in the optimistic locking value according the VersionType contract for the version property.
        参数:
        version - The current version
        versionType - The version type
        session - The originating session
        返回:
        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.
        参数:
        fields - The state snapshot
        version - The optimistic locking value
        persister - The entity persister
      • getVersion

        public static Object getVersion​(Object[] fields,
                                        EntityPersister persister)
        Extract the optimistic locking value out of the entity state snapshot.
        参数:
        fields - The state snapshot
        persister - The entity persister
        返回:
        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?
        参数:
        dirtyProperties - The array of property indexes which were deemed dirty
        hasDirtyCollections - Were any collections found to be dirty (structurally changed)
        propertyVersionability - An array indicating versionability of each property.
        返回:
        True if a version increment is required; false otherwise.