Class SimpleNaturalIdMapping
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.AbstractNaturalIdMapping
-
- org.hibernate.metamodel.mapping.internal.SimpleNaturalIdMapping
-
- All Implemented Interfaces:
Bindable,JdbcMappingContainer,MappingModelExpressible,ModelPart,NaturalIdMapping,VirtualModelPart,JavaType.CoercionContext
public class SimpleNaturalIdMapping extends AbstractNaturalIdMapping implements JavaType.CoercionContext
Single-attribute NaturalIdMapping implementation
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable
Bindable.JdbcValuesConsumer
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ModelPart
ModelPart.JdbcValueConsumer
-
-
Field Summary
-
Fields inherited from interface org.hibernate.metamodel.mapping.NaturalIdMapping
PART_NAME
-
-
Constructor Summary
Constructors Constructor Description SimpleNaturalIdMapping(SingularAttributeMapping attribute, EntityMappingType declaringType, MappingModelCreationProcess creationProcess)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.voidapplySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection,JdbcMapping> selectionConsumer)Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.voidbreakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)intcalculateHashCode(Object value, SharedSessionContractImplementor session)Calculate the hash-code of a natural-id value<T> DomainResult<T>createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)Create a DomainResult for a specific reference to this ModelPart.Objectdisassemble(Object value, SharedSessionContractImplementor session)ObjectextractNaturalIdFromEntity(Object entity, SharedSessionContractImplementor session)Given an entity instance, extract the normalized natural id representationObjectextractNaturalIdFromEntityState(Object[] state, SharedSessionContractImplementor session)Given an array of "full entity state", extract the normalized natural id representationintforEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)intforEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Visit each JdbcMapping starting from the given offsetintforEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)intforEachSelectable(int offset, SelectableConsumer consumer)SingularAttributeMappinggetAttribute()JavaType<?>getJavaType()List<JdbcMapping>getJdbcMappings()The list of JDBC mappingsintgetJdbcTypeCount()The number of JDBC mappingsList<SingularAttributeMapping>getNaturalIdAttributes()The attribute(s) making up the natural-id.MappingTypegetPartMappingType()TypeConfigurationgetTypeConfiguration()NaturalIdLoader<?>makeLoader(EntityMappingType entityDescriptor)Make a loader capable of loading a single entity by natural-idMultiNaturalIdLoader<?>makeMultiLoader(EntityMappingType entityDescriptor)Make a loader capable of loading multiple entities by natural-idObjectnormalizeIncomingValue(Object naturalIdToLoad)ObjectnormalizeInput(Object incoming, SharedSessionContractImplementor session)Normalize a user-provided natural-id value into the representation Hibernate uses internallyvoidvalidateInternalForm(Object naturalIdValue, SharedSessionContractImplementor session)Validates a natural id value(s) for the described natural-id based on the expected internal representationvoidverifyFlushState(Object id, Object[] currentState, Object[] loadedState, SharedSessionContractImplementor session)Verify the natural-id value(s) we are about to flush to the database-
Methods inherited from class org.hibernate.metamodel.mapping.internal.AbstractNaturalIdMapping
findContainingEntityMapping, getCacheAccess, getDeclaringType, getNavigableRole, isMutable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asAttributeMapping, forEachSelectable
-
Methods inherited from interface org.hibernate.metamodel.mapping.NaturalIdMapping
getPartName
-
-
-
-
Constructor Detail
-
SimpleNaturalIdMapping
public SimpleNaturalIdMapping(SingularAttributeMapping attribute, EntityMappingType declaringType, MappingModelCreationProcess creationProcess)
-
-
Method Detail
-
verifyFlushState
public void verifyFlushState(Object id, Object[] currentState, Object[] loadedState, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMappingVerify the natural-id value(s) we are about to flush to the database- Specified by:
verifyFlushStatein interfaceNaturalIdMapping
-
extractNaturalIdFromEntityState
public Object extractNaturalIdFromEntityState(Object[] state, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMappingGiven an array of "full entity state", extract the normalized natural id representation- Specified by:
extractNaturalIdFromEntityStatein interfaceNaturalIdMapping- Parameters:
state- The attribute state array- Returns:
- The extracted natural id values. This is a normalized
-
extractNaturalIdFromEntity
public Object extractNaturalIdFromEntity(Object entity, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMappingGiven an entity instance, extract the normalized natural id representation- Specified by:
extractNaturalIdFromEntityin interfaceNaturalIdMapping- Parameters:
entity- The entity instance- Returns:
- The extracted natural id values
-
validateInternalForm
public void validateInternalForm(Object naturalIdValue, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMappingValidates a natural id value(s) for the described natural-id based on the expected internal representation- Specified by:
validateInternalFormin interfaceNaturalIdMapping
-
calculateHashCode
public int calculateHashCode(Object value, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMappingCalculate the hash-code of a natural-id value- Specified by:
calculateHashCodein interfaceNaturalIdMapping- Parameters:
value- The natural-id value- Returns:
- The hash-code
-
normalizeInput
public Object normalizeInput(Object incoming, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMappingNormalize a user-provided natural-id value into the representation Hibernate uses internally- Specified by:
normalizeInputin interfaceNaturalIdMapping- Parameters:
incoming- The user-supplied value- Returns:
- The normalized, internal representation
-
getAttribute
public SingularAttributeMapping getAttribute()
-
getNaturalIdAttributes
public List<SingularAttributeMapping> getNaturalIdAttributes()
Description copied from interface:NaturalIdMappingThe attribute(s) making up the natural-id.- Specified by:
getNaturalIdAttributesin interfaceNaturalIdMapping
-
getPartMappingType
public MappingType getPartMappingType()
- Specified by:
getPartMappingTypein interfaceModelPart
-
getJavaType
public JavaType<?> getJavaType()
- Specified by:
getJavaTypein interfaceModelPart
-
createDomainResult
public <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Description copied from interface:ModelPartCreate a DomainResult for a specific reference to this ModelPart.- Specified by:
createDomainResultin interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)
Description copied from interface:ModelPartApply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelectionsin interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection,JdbcMapping> selectionConsumer)
Description copied from interface:ModelPartApply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelectionsin interfaceModelPart
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)- Specified by:
forEachSelectablein interfaceModelPart
-
getJdbcTypeCount
public int getJdbcTypeCount()
Description copied from interface:BindableThe number of JDBC mappings- Specified by:
getJdbcTypeCountin interfaceBindable- Specified by:
getJdbcTypeCountin interfaceJdbcMappingContainer
-
getJdbcMappings
public List<JdbcMapping> getJdbcMappings()
Description copied from interface:BindableThe list of JDBC mappings- Specified by:
getJdbcMappingsin interfaceBindable- Specified by:
getJdbcMappingsin interfaceJdbcMappingContainer
-
forEachJdbcType
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Description copied from interface:JdbcMappingContainerVisit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcTypein interfaceJdbcMappingContainer
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemblein interfaceBindable- See Also:
As an example, consider the following domain model: ````
-
breakDownJdbcValues
public void breakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)
- Specified by:
breakDownJdbcValuesin interfaceModelPart
-
forEachDisassembledJdbcValue
public int forEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachDisassembledJdbcValuein interfaceBindable
-
forEachJdbcValue
public int forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachJdbcValuein interfaceBindable
-
makeLoader
public NaturalIdLoader<?> makeLoader(EntityMappingType entityDescriptor)
Description copied from interface:NaturalIdMappingMake a loader capable of loading a single entity by natural-id- Specified by:
makeLoaderin interfaceNaturalIdMapping
-
makeMultiLoader
public MultiNaturalIdLoader<?> makeMultiLoader(EntityMappingType entityDescriptor)
Description copied from interface:NaturalIdMappingMake a loader capable of loading multiple entities by natural-id- Specified by:
makeMultiLoaderin interfaceNaturalIdMapping
-
getTypeConfiguration
public TypeConfiguration getTypeConfiguration()
- Specified by:
getTypeConfigurationin interfaceJavaType.CoercionContext
-
-