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,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 classCompoundNaturalIdMapping.DomainResultImpl-
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 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 voidaddToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.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.booleanareEqual(Object one, Object other, SharedSessionContractImplementor session)<X,Y>
intbreakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X,Y> valueConsumer, SharedSessionContractImplementor session)Breaks down the domain value to its constituent JDBC values.intcalculateHashCode(Object value)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)Breaks down a value ofJinto its simple pieces.Object[]extractNaturalIdFromEntity(Object entity)Given an entity instance, extract the normalized natural id representationObject[]extractNaturalIdFromEntityState(Object[] state)Given an array of "full entity state", extract the normalized natural id representationModelPartfindSubPart(String name, EntityMappingType treatTargetType)<X,Y>
intforEachDisassembledJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)LikeBindable.forEachDisassembledJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor), but additionally receives an offset by which the selectionIndex is incremented when callingBindable.JdbcValuesBiConsumer.consume(int, Object, Object, Object, JdbcMapping).intforEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Visit each JdbcMapping starting from the given offset<X,Y>
intforEachJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)Visit each constituent JDBC value extracted from the entity instance itself.intforEachSelectable(int offset, SelectableConsumer consumer)Visits each selectable mapping with the selectable index offset by the given value.voidforEachSubPart(IndexedConsumer<ModelPart> consumer, EntityMappingType treatTarget)FetchablegetFetchable(int position)JavaType<?>getJavaType()The Java type for this part.JdbcMappinggetJdbcMapping(int index)intgetJdbcTypeCount()The number of JDBC mappingsJavaType<?>getMappedJavaType()The descriptor descriptor for the mapped Java typeList<SingularAttributeMapping>getNaturalIdAttributes()The attribute(s) making up the natural-id.intgetNumberOfFetchableKeys()The number of fetchables in the containerintgetNumberOfFetchables()The number of fetchables in the containerMappingTypegetPartMappingType()The type for this part.booleanhasPartitionedSelectionMapping()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)Normalize a user-provided natural-id value into the representation Hibernate uses internallyvoidvalidateInternalForm(Object naturalIdValue)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 databasevoidvisitSubParts(Consumer<ModelPart> consumer, EntityMappingType treatTargetType)-
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, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue
-
Methods inherited from interface org.hibernate.sql.results.graph.FetchableContainer
getKeyFetchable, getNumberOfKeyFetchables, getSelectableIndex, visitFetchables, visitFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitKeyFetchables
-
Methods inherited from interface org.hibernate.metamodel.mapping.JdbcMappingContainer
getSingleJdbcMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
asAttributeMapping, asBasicValuedModelPart, asEntityMappingType, breakDownJdbcValues, decompose, decompose, findContainingEntityMapping, forEachSelectable, getNavigableRole, isEntityIdentifierMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPartContainer
findByPath, findByPath, forEachSubPart
-
Methods inherited from interface org.hibernate.metamodel.mapping.NaturalIdMapping
getPartName
-
Methods inherited from interface org.hibernate.metamodel.mapping.VirtualModelPart
isVirtual
-
-
-
-
Constructor Detail
-
CompoundNaturalIdMapping
public CompoundNaturalIdMapping(EntityMappingType declaringType, List<SingularAttributeMapping> attributes, MappingModelCreationProcess creationProcess)
-
-
Method Detail
-
extractNaturalIdFromEntityState
public Object[] extractNaturalIdFromEntityState(Object[] state)
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)
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
-
normalizeInput
public Object[] normalizeInput(Object incoming)
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
-
validateInternalForm
public void validateInternalForm(Object naturalIdValue)
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)
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
-
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
-
areEqual
public boolean areEqual(Object one, Object other, SharedSessionContractImplementor session)
-
getNaturalIdAttributes
public List<SingularAttributeMapping> getNaturalIdAttributes()
Description copied from interface:NaturalIdMappingThe attribute(s) making up the natural-id.- Specified by:
getNaturalIdAttributesin interfaceNaturalIdMapping
-
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
-
getPartMappingType
public MappingType getPartMappingType()
Description copied from interface:ModelPartThe type for this part.- Specified by:
getPartMappingTypein interfaceModelPart
-
getJavaType
public JavaType<?> getJavaType()
Description copied from interface:ModelPartThe Java type for this part. Generally equivalent toMappingType.getMappedJavaType()relative toModelPart.getPartMappingType()- Specified by:
getJavaTypein interfaceModelPart
-
getMappedJavaType
public JavaType<?> getMappedJavaType()
Description copied from interface:MappingTypeThe descriptor descriptor for the mapped Java type- Specified by:
getMappedJavaTypein interfaceMappingType
-
hasPartitionedSelectionMapping
public boolean hasPartitionedSelectionMapping()
- Specified by:
hasPartitionedSelectionMappingin 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
-
breakDownJdbcValues
public <X,Y> int breakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X,Y> valueConsumer, SharedSessionContractImplementor session)
Description copied from interface:ModelPartBreaks down the domain value to its constituent JDBC values. Think of it as breaking the multi-dimensional array into a visitable flat array. Additionally, it passes through the valuesXandYto the consumer. Returns the amount of jdbc types that have been visited.- Specified by:
breakDownJdbcValuesin interfaceModelPart
-
forEachSelectable
public int forEachSelectable(int offset, SelectableConsumer consumer)Description copied from interface:ModelPartVisits each selectable mapping with the selectable index offset by the given value. Returns the amount of jdbc types that have been visited.- 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
-
getJdbcMapping
public JdbcMapping getJdbcMapping(int index)
- Specified by:
getJdbcMappingin 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)
Description copied from interface:BindableBreaks down a value ofJinto its simple pieces. E.g., an embedded value gets broken down into an array of its attribute state; a basic value converts to itself; etc.Generally speaking, this is the form in which entity state is kept relative to a Session via
EntityEntry.@Entity class Person { @Id Integer id; @Embedded Name name; int age; } @Embeddable class Name { String familiarName; String familyName; }At the top level, we would want to disassemble a
Personvalue, so we'd ask theBindablefor thePersonentity to disassemble. Given aPersonvalue:Person( id=1, name=Name( 'Steve', 'Ebersole' ), 28 )
this disassemble would result in a multidimensional array:
[ ["Steve", "Ebersole"], 28 ]
Note that the identifier is not part of this disassembled state. Note also how the embedded value results in a sub-array.
- Specified by:
disassemblein interfaceBindable- See Also:
EntityEntry
-
addToCacheKey
public void addToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session)
Description copied from interface:BindableAdd to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.- Specified by:
addToCacheKeyin interfaceBindable- Parameters:
cacheKey- the MutableCacheKey used to add the disassembled value and the hashCodevalue- the value to disassemblesession- the SharedSessionContractImplementor
-
forEachDisassembledJdbcValue
public <X,Y> int forEachDisassembledJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)
Description copied from interface:BindableLikeBindable.forEachDisassembledJdbcValue(Object, Object, Object, JdbcValuesBiConsumer, SharedSessionContractImplementor), but additionally receives an offset by which the selectionIndex is incremented when callingBindable.JdbcValuesBiConsumer.consume(int, Object, Object, Object, JdbcMapping).- Specified by:
forEachDisassembledJdbcValuein interfaceBindable
-
forEachJdbcValue
public <X,Y> int forEachJdbcValue(Object value, int offset, X x, Y y, Bindable.JdbcValuesBiConsumer<X,Y> valuesConsumer, SharedSessionContractImplementor session)
Description copied from interface:BindableVisit each constituent JDBC value extracted from the entity instance itself. Short-hand form of callingBindable.disassemble(java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor)and piping its result toBindable.forEachDisassembledJdbcValue(Object, int, JdbcValuesConsumer, SharedSessionContractImplementor)- Specified by:
forEachJdbcValuein interfaceBindable
-
getNumberOfFetchables
public int getNumberOfFetchables()
Description copied from interface:FetchableContainerThe number of fetchables in the container- Specified by:
getNumberOfFetchablesin interfaceFetchableContainer
-
getFetchable
public Fetchable getFetchable(int position)
- Specified by:
getFetchablein interfaceFetchableContainer
-
findSubPart
public ModelPart findSubPart(String name, EntityMappingType treatTargetType)
- Specified by:
findSubPartin interfaceModelPartContainer
-
forEachSubPart
public void forEachSubPart(IndexedConsumer<ModelPart> consumer, EntityMappingType treatTarget)
- Specified by:
forEachSubPartin interfaceModelPartContainer
-
visitSubParts
public void visitSubParts(Consumer<ModelPart> consumer, EntityMappingType treatTargetType)
- Specified by:
visitSubPartsin interfaceModelPartContainer
-
getNumberOfFetchableKeys
public int getNumberOfFetchableKeys()
Description copied from interface:FetchableContainerThe number of fetchables in the container- Specified by:
getNumberOfFetchableKeysin interfaceFetchableContainer
-
-