Class VersionValue

  • All Implemented Interfaces:
    UnsavedValueStrategy

    public class VersionValue
    extends java.lang.Object
    implements UnsavedValueStrategy
    A strategy for determining if a version value is a version of a new transient instance or a previously persistent transient instance. The strategy is determined by the unsaved-value attribute in the mapping file.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static VersionValue NEGATIVE
      Assume the transient instance is newly instantiated if the version is negative, otherwise assume it is a detached instance.
      static VersionValue NULL
      Assume the transient instance is newly instantiated if the version is null, otherwise assume it is a detached instance.
      static VersionValue UNDEFINED
      Assume the transient instance is newly instantiated if the version is null, otherwise defer to the identifier unsaved-value.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected VersionValue()  
        VersionValue​(java.lang.Object value)
      Assume the transient instance is newly instantiated if its version is null or equal to value
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object getDefaultValue​(java.lang.Object currentValue)
      Get a default value meant to indicate transience.
      java.lang.Boolean isUnsaved​(java.lang.Object version)
      Make the transient/detached determination
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NULL

        public static final VersionValue NULL
        Assume the transient instance is newly instantiated if the version is null, otherwise assume it is a detached instance.
      • UNDEFINED

        public static final VersionValue UNDEFINED
        Assume the transient instance is newly instantiated if the version is null, otherwise defer to the identifier unsaved-value.
      • NEGATIVE

        public static final VersionValue NEGATIVE
        Assume the transient instance is newly instantiated if the version is negative, otherwise assume it is a detached instance.
    • Constructor Detail

      • VersionValue

        protected VersionValue()
      • VersionValue

        public VersionValue​(java.lang.Object value)
        Assume the transient instance is newly instantiated if its version is null or equal to value
        Parameters:
        value - value to compare to
    • Method Detail

      • isUnsaved

        public java.lang.Boolean isUnsaved​(java.lang.Object version)
                                    throws MappingException
        Description copied from interface: UnsavedValueStrategy
        Make the transient/detached determination
        Specified by:
        isUnsaved in interface UnsavedValueStrategy
        Parameters:
        version - The value to be tested
        Returns:
        true indicates the value corresponds to unsaved data (aka, transient state); false indicates the value does not corresponds to unsaved data (aka, detached state); null indicates that this strategy was not able to determine conclusively.
        Throws:
        MappingException
      • getDefaultValue

        public java.lang.Object getDefaultValue​(java.lang.Object currentValue)
        Description copied from interface: UnsavedValueStrategy
        Get a default value meant to indicate transience.
        Specified by:
        getDefaultValue in interface UnsavedValueStrategy
        Parameters:
        currentValue - The current state value.
        Returns:
        The default transience value.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object