Package org.hibernate.engine.spi
Class VersionValue
- java.lang.Object
-
- org.hibernate.engine.spi.VersionValue
-
- All Implemented Interfaces:
UnsavedValueStrategy
public class VersionValue extends 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 VersionValueNEGATIVEAssume the transient instance is newly instantiated if the version is negative, otherwise assume it is a detached instance.static VersionValueNULLAssume the transient instance is newly instantiated if the version is null, otherwise assume it is a detached instance.static VersionValueUNDEFINEDAssume the transient instance is newly instantiated if the version is null, otherwise defer to the identifier unsaved-value.
-
Constructor Summary
Constructors Modifier Constructor Description protectedVersionValue()VersionValue(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 ObjectgetDefaultValue(Object currentValue)Get a default value meant to indicate transience.BooleanisUnsaved(Object version)Make the transient/detached determinationStringtoString()
-
-
-
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(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 Boolean isUnsaved(Object version) throws MappingException
Description copied from interface:UnsavedValueStrategyMake the transient/detached determination- Specified by:
isUnsavedin interfaceUnsavedValueStrategy- Parameters:
version- The value to be tested- Returns:
trueindicates the value corresponds to unsaved data (aka, transient state);falseindicates the value does not corresponds to unsaved data (aka, detached state);nullindicates that this strategy was not able to determine conclusively.- Throws:
MappingException
-
getDefaultValue
public Object getDefaultValue(Object currentValue)
Description copied from interface:UnsavedValueStrategyGet a default value meant to indicate transience.- Specified by:
getDefaultValuein interfaceUnsavedValueStrategy- Parameters:
currentValue- The current state value.- Returns:
- The default transience value.
-
-