Class CoherenceRegionValue

  • All Implemented Interfaces:
    Serializable

    public class CoherenceRegionValue
    extends Object
    implements Serializable
    A CoherenceRegion.CoherenceRegionValue is an object representing a value in Hibernate's second-level cache. It holds the "actual" cache value, as well as a "version" object and a timestamp (i.e. a long) used by Hibernate. It further keeps track of its state with respect to soft-locked-ness, and the number of soft locks currently in effect on it.
    Author:
    Randy Stafford, Gunnar Hillert
    See Also:
    Serialized Form
    • Constructor Detail

      • CoherenceRegionValue

        public CoherenceRegionValue​(Object value,
                                    Object version,
                                    long timestamp)
        Complete constructor.
        Parameters:
        value - the actual value in this cache value
        version - the version of the actual value in this cache value
        timestamp - the timestamp of the actual value in this cache value
    • Method Detail

      • getValue

        public Object getValue()
        Returns the "actual" value in this cache value.
        Returns:
        the Object that is the "actual" value in this cache value
      • getVersion

        public Object getVersion()
        Returns the "version" of the "actual" value in this cache value.
        Returns:
        the Object that is the "version" of the "actual" value in this cache value
      • getTimestamp

        public long getTimestamp()
        Returns the "timestamp" of the "actual" value in this cache value.
        Returns:
        the long "timestamp" of the "actual" value in this cache value
      • equals

        public boolean equals​(Object someObject)
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • addSoftLock

        public void addSoftLock​(CoherenceRegionValue.SoftLock softLock)
        Adds a SoftLock to this cache value.
        Parameters:
        softLock - the SoftLock to add
      • isReplaceableFromLoad

        public boolean isReplaceableFromLoad​(long txTimestamp,
                                             Object replacementVersion,
                                             Comparator<Object> versionComparator)
        Returns a boolean indicating whether this cache value is replaceable from database load.
        Parameters:
        txTimestamp - From Hibernate javadoc, "a timestamp prior to the transaction start time" [where "the transaction" loaded the potential replacement value from database]
        replacementVersion - the version of the would-be replacement
        versionComparator - a Comparator for comparing entity versions
        Returns:
        a boolean indicating whether this cache value is replaceable from database load
      • isNotSoftLocked

        public boolean isNotSoftLocked()
        Returns a boolean indicating whether this cache value is not currently soft-locked.
        Returns:
        a boolean indicating whether this cache value is not currently soft-locked
      • isSoftLocked

        public boolean isSoftLocked()
        Returns a boolean indicating whether this cache value is currently soft-locked.
        Returns:
        a boolean indicating whether this cache value is currently soft-locked
      • releaseSoftLock

        public void releaseSoftLock​(org.hibernate.cache.spi.access.SoftLock softLock,
                                    long timeOfRelease)
        Attempts to release the argument SoftLock on this cache value. Has no effect if soft locks are not released in the same order in which they were acquired.
        Parameters:
        softLock - the SoftLock whose release to attempt
        timeOfRelease - the time at which the SoftLock was released