Package org.hibernate.engine.spi
Class IdentifierValue
- java.lang.Object
-
- org.hibernate.engine.spi.IdentifierValue
-
- All Implemented Interfaces:
UnsavedValueStrategy
public class IdentifierValue extends Object implements UnsavedValueStrategy
A strategy for determining if an identifier value is an identifier of a new transient instance or a previously persistent transient instance. The strategy is determined by theunsaved-value
attribute in the mapping file.
-
-
Field Summary
Fields Modifier and Type Field Description static IdentifierValue
ANY
Always assume the transient instance is newly instantiatedstatic IdentifierValue
NONE
Never assume the transient instance is newly instantiatedstatic IdentifierValue
NULL
Assume the transient instance is newly instantiated if the identifier is null.static IdentifierValue
UNDEFINED
Assume nothing.
-
Constructor Summary
Constructors Modifier Constructor Description protected
IdentifierValue()
IdentifierValue(Object value)
Assume the transient instance is newly instantiated if its identifier is null or equal tovalue
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable Object
getDefaultValue(@Nullable Object currentValue)
Get a default value meant to indicate transience.@Nullable Boolean
isUnsaved(@Nullable Object id)
Does the given identifier belong to a new instance?String
toString()
-
-
-
Field Detail
-
ANY
public static final IdentifierValue ANY
Always assume the transient instance is newly instantiated
-
NONE
public static final IdentifierValue NONE
Never assume the transient instance is newly instantiated
-
NULL
public static final IdentifierValue NULL
Assume the transient instance is newly instantiated if the identifier is null.
-
UNDEFINED
public static final IdentifierValue UNDEFINED
Assume nothing.
-
-
Constructor Detail
-
IdentifierValue
protected IdentifierValue()
-
IdentifierValue
public IdentifierValue(Object value)
Assume the transient instance is newly instantiated if its identifier is null or equal tovalue
-
-
Method Detail
-
isUnsaved
public @Nullable Boolean isUnsaved(@Nullable Object id)
Does the given identifier belong to a new instance?- Specified by:
isUnsaved
in interfaceUnsavedValueStrategy
- Parameters:
id
- 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.
-
getDefaultValue
public @Nullable Object getDefaultValue(@Nullable Object currentValue)
Description copied from interface:UnsavedValueStrategy
Get a default value meant to indicate transience.- Specified by:
getDefaultValue
in interfaceUnsavedValueStrategy
- Parameters:
currentValue
- The current state value.- Returns:
- The default transience value.
-
-