Package org.hibernate.metamodel.mapping
Interface NaturalIdMapping
- All Superinterfaces:
Bindable
,JdbcMappingContainer
,MappingModelExpressible
,ModelPart
,VirtualModelPart
- All Known Implementing Classes:
AbstractNaturalIdMapping
,CompoundNaturalIdMapping
,SimpleNaturalIdMapping
Mapping for an entity's natural-id, if one is defined.
Natural identifiers are an alternative form of uniquely
identifying a specific row. In this sense, they are similar
to a primary key. In fact most natural identifiers will also
be classified as "candidate keys" (as in a column or group of
columns that are considered candidates for primary-key).
However, a natural id has fewer restrictions than a primary
key. While these lessened restrictions make them inappropriate
for use as a primary key, they are still generally usable as
unique locators with caveats. General reasons a natural id
might be inappropriate for use as a primary key are
- it contains nullable values
- it contains modifiable values
See other sources for a more complete discussion of data modeling.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable
Bindable.JdbcValuesBiConsumer<X,
Y>, Bindable.JdbcValuesConsumer Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ModelPart
ModelPart.JdbcValueBiConsumer<X,
Y>, ModelPart.JdbcValueConsumer -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
calculateHashCode
(Object value) Calculate the hash-code of a natural-id valueextractNaturalIdFromEntity
(Object entity) Given an entity instance, extract the normalized natural id representationextractNaturalIdFromEntityState
(Object[] state) Given an array of "full entity state", extract the normalized natural id representationAccess to the natural-id's L2 cache access.The attribute(s) making up the natural-id.default String
The local part name, which is generally the unqualified role nameboolean
Whether the natural-id is mutable.makeLoader
(EntityMappingType entityDescriptor) Make a loader capable of loading a single entity by natural-idmakeMultiLoader
(EntityMappingType entityDescriptor) Make a loader capable of loading multiple entities by natural-idnormalizeInput
(Object incoming) Normalize a user-provided natural-id value into the representation Hibernate uses internallyvoid
validateInternalForm
(Object naturalIdValue) Validates a natural id value(s) for the described natural-id based on the expected internal representationvoid
verifyFlushState
(Object id, Object[] currentState, Object[] loadedState, SharedSessionContractImplementor session) Verify the natural-id value(s) we are about to flush to the databaseMethods inherited from interface org.hibernate.metamodel.mapping.Bindable
addToCacheKey, disassemble, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue, getJdbcTypeCount
Methods inherited from interface org.hibernate.metamodel.mapping.JdbcMappingContainer
forEachJdbcType, getJdbcMapping, getSingleJdbcMapping
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
applySqlSelections, applySqlSelections, areEqual, asAttributeMapping, asBasicValuedModelPart, asEntityMappingType, breakDownJdbcValues, breakDownJdbcValues, createDomainResult, decompose, decompose, findContainingEntityMapping, forEachSelectable, forEachSelectable, getJavaType, getNavigableRole, getPartMappingType, hasPartitionedSelectionMapping, isEntityIdentifierMapping
Methods inherited from interface org.hibernate.metamodel.mapping.VirtualModelPart
isVirtual
-
Field Details
-
PART_NAME
- See Also:
-
-
Method Details
-
getNaturalIdAttributes
List<SingularAttributeMapping> getNaturalIdAttributes()The attribute(s) making up the natural-id. -
isMutable
boolean isMutable()Whether the natural-id is mutable.- API Note:
- For compound natural-ids, this is true if any of the attributes are mutable.
-
getPartName
Description copied from interface:ModelPart
The local part name, which is generally the unqualified role name- Specified by:
getPartName
in interfaceModelPart
-
getCacheAccess
NaturalIdDataAccess getCacheAccess()Access to the natural-id's L2 cache access. Returns null if the natural-id is not configured for caching -
extractNaturalIdFromEntityState
Given an array of "full entity state", extract the normalized natural id representation- Parameters:
state
- The attribute state array- Returns:
- The extracted natural id values. This is a normalized
-
extractNaturalIdFromEntity
Given an entity instance, extract the normalized natural id representation- Parameters:
entity
- The entity instance- Returns:
- The extracted natural id values
-
normalizeInput
Normalize a user-provided natural-id value into the representation Hibernate uses internally- Parameters:
incoming
- The user-supplied value- Returns:
- The normalized, internal representation
-
validateInternalForm
Validates a natural id value(s) for the described natural-id based on the expected internal representation -
calculateHashCode
Calculate the hash-code of a natural-id value- Parameters:
value
- The natural-id value- Returns:
- The hash-code
-
makeLoader
Make a loader capable of loading a single entity by natural-id -
makeMultiLoader
Make a loader capable of loading multiple entities by natural-id
-