Class CompoundNaturalIdMapping
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.AbstractNaturalIdMapping
-
- org.hibernate.metamodel.mapping.internal.CompoundNaturalIdMapping
-
- All Implemented Interfaces:
Bindable
,JdbcMappingContainer
,MappingModelExpressible
,MappingType
,ModelPart
,ModelPartContainer
,NaturalIdMapping
,Queryable
,VirtualModelPart
,FetchableContainer
public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implements MappingType, FetchableContainer
Multi-attribute NaturalIdMapping implementation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompoundNaturalIdMapping.DomainResultImpl
-
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 CompoundNaturalIdMapping(EntityMappingType declaringType, List<SingularAttributeMapping> attributes, MappingModelCreationProcess creationProcess)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)
Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.void
applySqlSelections(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.boolean
areEqual(Object one, Object other, SharedSessionContractImplementor session)
void
breakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)
int
calculateHashCode(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.Object
disassemble(Object value, SharedSessionContractImplementor session)
Object[]
extractNaturalIdFromEntity(Object entity, SharedSessionContractImplementor session)
Given an entity instance, extract the normalized natural id representationObject[]
extractNaturalIdFromEntityState(Object[] state, SharedSessionContractImplementor session)
Given an array of "full entity state", extract the normalized natural id representationModelPart
findSubPart(String name, EntityMappingType treatTargetType)
For an entity, this form allows for Hibernate's "implicit treat" support - meaning it should find a sub-part whether defined on the entity, its super-type or even one of its sub-types.int
forEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
int
forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)
Visit each JdbcMapping starting from the given offsetint
forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
int
forEachSelectable(int offset, SelectableConsumer consumer)
Fetchable
getFetchable(int position)
JavaType<?>
getJavaType()
List<JdbcMapping>
getJdbcMappings()
The list of JDBC mappingsint
getJdbcTypeCount()
The number of JDBC mappingsJavaType<?>
getMappedJavaType()
List<SingularAttributeMapping>
getNaturalIdAttributes()
The attribute(s) making up the natural-id.int
getNumberOfFetchables()
The number of fetchables in the containerMappingType
getPartMappingType()
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-idObject[]
normalizeInput(Object incoming, SharedSessionContractImplementor session)
Normalize a user-provided natural-id value into the representation Hibernate uses internallyvoid
validateInternalForm(Object naturalIdValue, SharedSessionContractImplementor session)
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 databasevoid
visitSubParts(Consumer<ModelPart> consumer, EntityMappingType treatTargetType)
LikeQueryable.findSubPart(java.lang.String, org.hibernate.metamodel.mapping.EntityMappingType)
, this form visits all parts defined on the entity, its super-types and its sub-types.-
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.sql.results.graph.FetchableContainer
getKeyFetchable, getNumberOfKeyFetchables, visitFetchables, visitFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitKeyFetchables
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
asAttributeMapping, findContainingEntityMapping, forEachSelectable, getNavigableRole
-
Methods inherited from interface org.hibernate.metamodel.mapping.NaturalIdMapping
getPartName
-
Methods inherited from interface org.hibernate.metamodel.mapping.Queryable
findByPath, findSubTypesSubPart, resolveSubPart
-
-
-
-
Constructor Detail
-
CompoundNaturalIdMapping
public CompoundNaturalIdMapping(EntityMappingType declaringType, List<SingularAttributeMapping> attributes, MappingModelCreationProcess creationProcess)
-
-
Method Detail
-
extractNaturalIdFromEntityState
public Object[] extractNaturalIdFromEntityState(Object[] state, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMapping
Given an array of "full entity state", extract the normalized natural id representation- Specified by:
extractNaturalIdFromEntityState
in 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:NaturalIdMapping
Given an entity instance, extract the normalized natural id representation- Specified by:
extractNaturalIdFromEntity
in interfaceNaturalIdMapping
- Parameters:
entity
- The entity instance- Returns:
- The extracted natural id values
-
normalizeInput
public Object[] normalizeInput(Object incoming, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMapping
Normalize a user-provided natural-id value into the representation Hibernate uses internally- Specified by:
normalizeInput
in interfaceNaturalIdMapping
- Parameters:
incoming
- The user-supplied value- Returns:
- The normalized, internal representation
-
validateInternalForm
public void validateInternalForm(Object naturalIdValue, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMapping
Validates a natural id value(s) for the described natural-id based on the expected internal representation- Specified by:
validateInternalForm
in interfaceNaturalIdMapping
-
calculateHashCode
public int calculateHashCode(Object value, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMapping
Calculate the hash-code of a natural-id value- Specified by:
calculateHashCode
in interfaceNaturalIdMapping
- Parameters:
value
- The natural-id value- Returns:
- The hash-code
-
verifyFlushState
public void verifyFlushState(Object id, Object[] currentState, Object[] loadedState, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdMapping
Verify the natural-id value(s) we are about to flush to the database- Specified by:
verifyFlushState
in interfaceNaturalIdMapping
-
areEqual
public boolean areEqual(Object one, Object other, SharedSessionContractImplementor session)
-
getNaturalIdAttributes
public List<SingularAttributeMapping> getNaturalIdAttributes()
Description copied from interface:NaturalIdMapping
The attribute(s) making up the natural-id.- Specified by:
getNaturalIdAttributes
in interfaceNaturalIdMapping
-
makeLoader
public NaturalIdLoader<?> makeLoader(EntityMappingType entityDescriptor)
Description copied from interface:NaturalIdMapping
Make a loader capable of loading a single entity by natural-id- Specified by:
makeLoader
in interfaceNaturalIdMapping
-
makeMultiLoader
public MultiNaturalIdLoader<?> makeMultiLoader(EntityMappingType entityDescriptor)
Description copied from interface:NaturalIdMapping
Make a loader capable of loading multiple entities by natural-id- Specified by:
makeMultiLoader
in interfaceNaturalIdMapping
-
getPartMappingType
public MappingType getPartMappingType()
- Specified by:
getPartMappingType
in interfaceModelPart
-
getJavaType
public JavaType<?> getJavaType()
- Specified by:
getJavaType
in interfaceModelPart
-
getMappedJavaType
public JavaType<?> getMappedJavaType()
- Specified by:
getMappedJavaType
in interfaceMappingType
-
createDomainResult
public <T> DomainResult<T> createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Description copied from interface:ModelPart
Create a DomainResult for a specific reference to this ModelPart.- Specified by:
createDomainResult
in interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState)
Description copied from interface:ModelPart
Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelections
in interfaceModelPart
-
applySqlSelections
public void applySqlSelections(NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState, BiConsumer<SqlSelection,JdbcMapping> selectionConsumer)
Description copied from interface:ModelPart
Apply SQL selections for a specific reference to this ModelPart outside the domain query's root select clause.- Specified by:
applySqlSelections
in interfaceModelPart
-
breakDownJdbcValues
public void breakDownJdbcValues(Object domainValue, ModelPart.JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session)
- Specified by:
breakDownJdbcValues
in interfaceModelPart
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)
- Specified by:
forEachSelectable
in interfaceModelPart
-
getJdbcTypeCount
public int getJdbcTypeCount()
Description copied from interface:Bindable
The number of JDBC mappings- Specified by:
getJdbcTypeCount
in interfaceBindable
- Specified by:
getJdbcTypeCount
in interfaceJdbcMappingContainer
-
getJdbcMappings
public List<JdbcMapping> getJdbcMappings()
Description copied from interface:Bindable
The list of JDBC mappings- Specified by:
getJdbcMappings
in interfaceBindable
- Specified by:
getJdbcMappings
in interfaceJdbcMappingContainer
-
forEachJdbcType
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)
Description copied from interface:JdbcMappingContainer
Visit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcType
in interfaceJdbcMappingContainer
-
disassemble
public Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemble
in interfaceBindable
- See Also:
As an example, consider the following domain model: ````
-
forEachDisassembledJdbcValue
public int forEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachDisassembledJdbcValue
in interfaceBindable
-
forEachJdbcValue
public int forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachJdbcValue
in interfaceBindable
-
getNumberOfFetchables
public int getNumberOfFetchables()
Description copied from interface:FetchableContainer
The number of fetchables in the container- Specified by:
getNumberOfFetchables
in interfaceFetchableContainer
-
getFetchable
public Fetchable getFetchable(int position)
- Specified by:
getFetchable
in interfaceFetchableContainer
-
findSubPart
public ModelPart findSubPart(String name, EntityMappingType treatTargetType)
Description copied from interface:Queryable
For an entity, this form allows for Hibernate's "implicit treat" support - meaning it should find a sub-part whether defined on the entity, its super-type or even one of its sub-types.- Specified by:
findSubPart
in interfaceQueryable
-
visitSubParts
public void visitSubParts(Consumer<ModelPart> consumer, EntityMappingType treatTargetType)
Description copied from interface:Queryable
LikeQueryable.findSubPart(java.lang.String, org.hibernate.metamodel.mapping.EntityMappingType)
, this form visits all parts defined on the entity, its super-types and its sub-types.- Specified by:
visitSubParts
in interfaceQueryable
-
-