Class AbstractEmbeddableMapping
- java.lang.Object
-
- org.hibernate.metamodel.mapping.internal.AbstractEmbeddableMapping
-
- All Implemented Interfaces:
Bindable,EmbeddableMappingType,EmbeddableMappingType.ConcreteEmbeddableType,JdbcMappingContainer,ManagedMappingType,MappingModelExpressible,MappingType,ModelPart,ModelPartContainer,SelectableMappings,FetchableContainer
- Direct Known Subclasses:
EmbeddableMappingTypeImpl,IdClassEmbeddable,VirtualIdEmbeddable
public abstract class AbstractEmbeddableMapping extends Object implements EmbeddableMappingType, EmbeddableMappingType.ConcreteEmbeddableType
Base support for EmbeddableMappingType implementations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceAbstractEmbeddableMapping.AttributeTypeValidatorprotected static interfaceAbstractEmbeddableMapping.ConcreteTableResolverprotected static classAbstractEmbeddableMapping.IllegalAttributeTypeprotected static interfaceAbstractEmbeddableMapping.SuccessfulCompletionCallback-
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.EmbeddableMappingType
EmbeddableMappingType.ConcreteEmbeddableType
-
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ModelPart
ModelPart.JdbcValueBiConsumer<X,Y>, ModelPart.JdbcValueConsumer
-
-
Field Summary
Fields Modifier and Type Field Description protected MutableAttributeMappingListattributeMappingsprotected Getter[]getterCacheprotected SelectableMappingsselectableMappingsprotected Setter[]setterCache
-
Constructor Summary
Constructors Constructor Description AbstractEmbeddableMapping(MutableAttributeMappingList attributeMappings)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAttribute(AttributeMapping attributeMapping)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.<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.protected voidbuildGetterSetterCache()booleandeclaresAttribute(int attributeIndex)booleandeclaresAttribute(AttributeMapping attributeMapping)Returnstrueif the provided embeddable class contains the specified attribute mapping,falseotherwise.protected StringdetermineEmbeddablePrefix()Objectdisassemble(Object value, SharedSessionContractImplementor session)Breaks down a value ofJinto its simple pieces.AttributeMappingfindAttributeMapping(String name)Find an attribute by name.ModelPartfindSubPart(String name, EntityMappingType treatTargetType)protected booleanfinishInitialization(NavigableRole navigableRole, Component bootDescriptor, CompositeType compositeType, String rootTableExpression, String[] rootTableKeyColumnNames, EmbeddableMappingType declarer, EmbeddableRepresentationStrategy representationStrategy, AbstractEmbeddableMapping.AttributeTypeValidator attributeTypeValidator, AbstractEmbeddableMapping.ConcreteTableResolver concreteTableResolver, Consumer<AttributeMapping> attributeConsumer, AbstractEmbeddableMapping.SuccessfulCompletionCallback completionCallback, MappingModelCreationProcess creationProcess)voidforEachAttributeMapping(Consumer<? super AttributeMapping> action)Visit attributes defined on this class and any supersvoidforEachAttributeMapping(IndexedConsumer<? super AttributeMapping> consumer)Visit attributes defined on this class and any supers<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.intforEachSelectable(SelectableConsumer consumer)A short hand form ofModelPart.forEachSelectable(int, SelectableConsumer), that passes 0 as offset.voidforEachSubPart(IndexedConsumer<ModelPart> consumer, EntityMappingType treatTarget)AttributeMappinggetAttributeMapping(int position)Retrieve an attribute by its contributor positionAttributeMappingsListgetAttributeMappings()Get access to the attributes defined on this class and any supersprotected Object[]getAttributeValues(Object compositeInstance)Collection<EmbeddableMappingType.ConcreteEmbeddableType>getConcreteEmbeddableTypes()Returns the concrete embeddable subtypes or an empty collection ifEmbeddableMappingType.isPolymorphic()isfalse.ObjectgetDiscriminatorValue()FetchablegetFetchable(int position)EmbeddableInstantiatorgetInstantiator()JdbcMappinggetJdbcMapping(int index)intgetJdbcTypeCount()The number of JDBC mappingsJavaType<?>getMappedJavaType()The descriptor descriptor for the mapped Java typeintgetNumberOfAttributeMappings()Get the number of attributes defined on this class and any supersintgetNumberOfFetchables()The number of fetchables in the containerSelectableMappinggetSelectable(int columnIndex)Get the selectable at the given positionprotected SelectableMappingsgetSelectableMappings()intgetSubclassId()ObjectgetValue(Object instance, int position)Extract a specific attribute value from the entity instance, by positionObject[]getValues(Object compositeInstance)Extract the individual attribute values from the entity instanceprotected booleaninitColumnMappings()protected booleaninverseInitializeCallback(TableGroupProducer declaringTableGroupProducer, SelectableMappings selectableMappings, EmbeddableMappingType inverseMappingType, MappingModelCreationProcess creationProcess, ManagedMappingType declaringType, MutableAttributeMappingList mappings)protected voidsetAttributeValues(Object component, Object[] values)voidsetValue(Object instance, int position, Object value)Inject a specific attribute value into the entity instance, by positionvoidsetValues(Object component, Object[] values)Inject the attribute values into the entity instancevoidvisitFetchables(Consumer<? super Fetchable> consumer, EntityMappingType treatTargetType)voidvisitFetchables(IndexedConsumer<? super Fetchable> indexedConsumer, EntityMappingType treatTargetType)voidvisitSubParts(Consumer<ModelPart> consumer, EntityMappingType treatTargetType)-
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.metamodel.mapping.EmbeddableMappingType
anyRequiresAggregateColumnWriter, applySqlSelections, applySqlSelections, compare, createDomainResult, createInverseMappingType, findSubtypeByDiscriminator, findSubtypeBySubclass, forEachInsertable, forEachUpdatable, getAggregateMapping, getDiscriminatorMapping, getEmbeddedValueMapping, getJdbcValueCount, getJdbcValueSelectable, getPartMappingType, getRepresentationStrategy, getSelectableIndex, isCreateEmptyCompositesEnabled, isPolymorphic, requiresAggregateColumnWriter, shouldBindAggregateMapping, shouldMutateAggregateMapping, shouldSelectAggregateMapping
-
Methods inherited from interface org.hibernate.sql.results.graph.FetchableContainer
getKeyFetchable, getNumberOfFetchableKeys, getNumberOfKeyFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitKeyFetchables
-
Methods inherited from interface org.hibernate.metamodel.mapping.JdbcMappingContainer
getSingleJdbcMapping
-
Methods inherited from interface org.hibernate.metamodel.mapping.ManagedMappingType
getJavaType, hasPartitionedSelectionMapping, isAffectedByEnabledFilters
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asAttributeMapping, asBasicValuedModelPart, asEntityMappingType, breakDownJdbcValues, decompose, decompose, findContainingEntityMapping, getNavigableRole, getPartName, isEntityIdentifierMapping, isVirtual
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPartContainer
findByPath, findByPath, forEachSubPart
-
-
-
-
Field Detail
-
attributeMappings
protected final MutableAttributeMappingList attributeMappings
-
selectableMappings
protected SelectableMappings selectableMappings
-
getterCache
protected Getter[] getterCache
-
setterCache
protected Setter[] setterCache
-
-
Constructor Detail
-
AbstractEmbeddableMapping
public AbstractEmbeddableMapping(MutableAttributeMappingList attributeMappings)
-
-
Method Detail
-
getInstantiator
public EmbeddableInstantiator getInstantiator()
- Specified by:
getInstantiatorin interfaceEmbeddableMappingType.ConcreteEmbeddableType
-
getSubclassId
public int getSubclassId()
- Specified by:
getSubclassIdin interfaceEmbeddableMappingType.ConcreteEmbeddableType
-
getConcreteEmbeddableTypes
public Collection<EmbeddableMappingType.ConcreteEmbeddableType> getConcreteEmbeddableTypes()
Description copied from interface:EmbeddableMappingTypeReturns the concrete embeddable subtypes or an empty collection ifEmbeddableMappingType.isPolymorphic()isfalse.- Specified by:
getConcreteEmbeddableTypesin interfaceEmbeddableMappingType
-
declaresAttribute
public boolean declaresAttribute(AttributeMapping attributeMapping)
Description copied from interface:EmbeddableMappingType.ConcreteEmbeddableTypeReturnstrueif the provided embeddable class contains the specified attribute mapping,falseotherwise.- Specified by:
declaresAttributein interfaceEmbeddableMappingType.ConcreteEmbeddableType- Parameters:
attributeMapping- the attribute to check
-
declaresAttribute
public boolean declaresAttribute(int attributeIndex)
- Specified by:
declaresAttributein interfaceEmbeddableMappingType.ConcreteEmbeddableType
-
getValue
public Object getValue(Object instance, int position)
Description copied from interface:ManagedMappingTypeExtract a specific attribute value from the entity instance, by position- Specified by:
getValuein interfaceManagedMappingType
-
setValue
public void setValue(Object instance, int position, Object value)
Description copied from interface:ManagedMappingTypeInject a specific attribute value into the entity instance, by position- Specified by:
setValuein interfaceManagedMappingType
-
getDiscriminatorValue
public Object getDiscriminatorValue()
- Specified by:
getDiscriminatorValuein interfaceEmbeddableMappingType.ConcreteEmbeddableType
-
getMappedJavaType
public JavaType<?> getMappedJavaType()
Description copied from interface:MappingTypeThe descriptor descriptor for the mapped Java type- Specified by:
getMappedJavaTypein interfaceMappingType
-
getValues
public Object[] getValues(Object compositeInstance)
Description copied from interface:ManagedMappingTypeExtract the individual attribute values from the entity instance- Specified by:
getValuesin interfaceManagedMappingType
-
setValues
public void setValues(Object component, Object[] values)
Description copied from interface:ManagedMappingTypeInject the attribute values into the entity instance- Specified by:
setValuesin interfaceManagedMappingType
-
inverseInitializeCallback
protected boolean inverseInitializeCallback(TableGroupProducer declaringTableGroupProducer, SelectableMappings selectableMappings, EmbeddableMappingType inverseMappingType, MappingModelCreationProcess creationProcess, ManagedMappingType declaringType, MutableAttributeMappingList mappings)
-
finishInitialization
protected boolean finishInitialization(NavigableRole navigableRole, Component bootDescriptor, CompositeType compositeType, String rootTableExpression, String[] rootTableKeyColumnNames, EmbeddableMappingType declarer, EmbeddableRepresentationStrategy representationStrategy, AbstractEmbeddableMapping.AttributeTypeValidator attributeTypeValidator, AbstractEmbeddableMapping.ConcreteTableResolver concreteTableResolver, Consumer<AttributeMapping> attributeConsumer, AbstractEmbeddableMapping.SuccessfulCompletionCallback completionCallback, MappingModelCreationProcess creationProcess)
-
determineEmbeddablePrefix
protected String determineEmbeddablePrefix()
-
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
-
visitFetchables
public void visitFetchables(Consumer<? super Fetchable> consumer, EntityMappingType treatTargetType)
- Specified by:
visitFetchablesin interfaceFetchableContainer
-
visitFetchables
public void visitFetchables(IndexedConsumer<? super Fetchable> indexedConsumer, EntityMappingType treatTargetType)
- Specified by:
visitFetchablesin interfaceFetchableContainer
-
getNumberOfAttributeMappings
public int getNumberOfAttributeMappings()
Description copied from interface:ManagedMappingTypeGet the number of attributes defined on this class and any supers- Specified by:
getNumberOfAttributeMappingsin interfaceManagedMappingType
-
getAttributeMapping
public AttributeMapping getAttributeMapping(int position)
Description copied from interface:ManagedMappingTypeRetrieve an attribute by its contributor position- Specified by:
getAttributeMappingin interfaceManagedMappingType
-
findAttributeMapping
public AttributeMapping findAttributeMapping(String name)
Description copied from interface:ManagedMappingTypeFind an attribute by name.- Specified by:
findAttributeMappingin interfaceManagedMappingType- Returns:
- The named attribute, or
nullif no match was found
-
getAttributeMappings
public AttributeMappingsList getAttributeMappings()
Description copied from interface:ManagedMappingTypeGet access to the attributes defined on this class and any supers- Specified by:
getAttributeMappingsin interfaceManagedMappingType
-
getSelectable
public SelectableMapping getSelectable(int columnIndex)
Description copied from interface:SelectableMappingsGet the selectable at the given position- Specified by:
getSelectablein interfaceSelectableMappings
-
forEachSelectable
public int forEachSelectable(SelectableConsumer consumer)
Description copied from interface:ModelPartA short hand form ofModelPart.forEachSelectable(int, SelectableConsumer), that passes 0 as offset.- Specified by:
forEachSelectablein interfaceEmbeddableMappingType- Specified by:
forEachSelectablein interfaceModelPart- Specified by:
forEachSelectablein interfaceSelectableMappings
-
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 interfaceEmbeddableMappingType- Specified by:
forEachSelectablein interfaceModelPart- Specified by:
forEachSelectablein interfaceSelectableMappings- See Also:
SelectableConsumer.accept(int, SelectableMapping)
-
getJdbcTypeCount
public int getJdbcTypeCount()
Description copied from interface:BindableThe number of JDBC mappings- Specified by:
getJdbcTypeCountin interfaceBindable- Specified by:
getJdbcTypeCountin interfaceEmbeddableMappingType- Specified by:
getJdbcTypeCountin interfaceJdbcMappingContainer- Specified by:
getJdbcTypeCountin interfaceSelectableMappings
-
forEachJdbcType
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Description copied from interface:JdbcMappingContainerVisit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcTypein interfaceEmbeddableMappingType- Specified by:
forEachJdbcTypein interfaceJdbcMappingContainer
-
getJdbcMapping
public JdbcMapping getJdbcMapping(int index)
- Specified by:
getJdbcMappingin interfaceJdbcMappingContainer
-
forEachAttributeMapping
public void forEachAttributeMapping(IndexedConsumer<? super AttributeMapping> consumer)
Description copied from interface:ManagedMappingTypeVisit attributes defined on this class and any supers- Specified by:
forEachAttributeMappingin interfaceManagedMappingType
-
forEachAttributeMapping
public void forEachAttributeMapping(Consumer<? super AttributeMapping> action)
Description copied from interface:ManagedMappingTypeVisit attributes defined on this class and any supers- Specified by:
forEachAttributeMappingin interfaceManagedMappingType
-
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
-
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
-
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
-
addAttribute
protected void addAttribute(AttributeMapping attributeMapping)
-
getSelectableMappings
protected SelectableMappings getSelectableMappings()
-
initColumnMappings
protected boolean initColumnMappings()
-
buildGetterSetterCache
protected void buildGetterSetterCache()
-
-