Package org.hibernate.metamodel.mapping
Interface EntityMappingType
-
- All Superinterfaces:
Bindable,Discriminatable,EntityValuedModelPart,FetchableContainer,FilterRestrictable,JdbcMappingContainer,Loadable,ManagedMappingType,MappingModelExpressible,MappingType,ModelPart,ModelPartContainer,Queryable,Restrictable,RootTableGroupProducer,TableGroupProducer,WhereRestrictable
- All Known Subinterfaces:
EntityPersister,Loadable,Lockable,OuterJoinLoadable,PostInsertIdentityPersister,Queryable,SQLLoadable,UniqueKeyLoadable
- All Known Implementing Classes:
AbstractEntityPersister,AnonymousTupleEntityValuedModelPart,JoinedSubclassEntityPersister,SingleTableEntityPersister,UnionSubclassEntityPersister
public interface EntityMappingType extends ManagedMappingType, EntityValuedModelPart, Loadable, Restrictable, Discriminatable
Mapping of an entity- See Also:
Entity
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceEntityMappingType.ConstraintOrderedTableConsumer-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default voidapplyBaseRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, Set<String> treatAsDeclarations, SqlAstCreationState creationState)Applies the base set of restrictions.default voidapplyDiscriminator(Consumer<Predicate> predicateConsumer, String alias, TableGroup tableGroup, SqlAstCreationState creationState)default voidapplyFilterRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, SqlAstCreationState creationState)Applies just theFiltervalues enabled for the associated entityvoidapplySqlSelections(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.default voidapplyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState)Apply theWhererestrictions<T> DomainResult<T>createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)Create a DomainResult for a specific reference to this ModelPart.default TableReferencecreatePrimaryTableReference(SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)default TableGroupcreateRootTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAliasBase sqlAliasBase, SqlExpressionResolver expressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext)default TableGroupcreateRootTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAstCreationState creationState, SqlAstCreationContext creationContext)Create a root TableGroup as defined by this producerdefault TableReferenceJoincreateTableReferenceJoin(String joinTableExpression, SqlAliasBase sqlAliasBase, TableReference lhs, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)Objectdisassemble(Object value, SharedSessionContractImplementor session)default Object[]extractConcreteTypeStateValues(Map<AttributeMapping,DomainResultAssembler> assemblerMapping, RowProcessingState rowProcessingState)Deprecated, for removal: This API element is subject to removal in a future version.default EntityMappingTypefindContainingEntityMapping()AttributeMappingfindDeclaredAttributeMapping(String name)default ModelPartfindSubPart(String name)ModelPartfindSubPart(String name, EntityMappingType targetType)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.intforEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)intforEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Visit each JdbcMapping starting from the given offsetdefault intforEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)default AttributeMappinggetAttributeMapping(int position)Retrieve an attribute by its contributor positiondefault List<AttributeMapping>getAttributeMappings()Get access to the attributes defined on this class and any supersdefault StringgetContributor()Collection<AttributeMapping>getDeclaredAttributeMappings()Get access to the attributes defined on this class - do not access attributes defined on the superEntityDiscriminatorMappinggetDiscriminatorMapping()ObjectgetDiscriminatorValue()StringgetEntityName()EntityPersistergetEntityPersister()Safety-net.default FetchablegetFetchable(int position)EntityIdentifierMappinggetIdentifierMapping()default JavaType<?>getJavaType()default intgetJdbcTypeCount()The number of JDBC mappingsdefault JavaTypegetMappedJavaType()MultiNaturalIdLoader<?>getMultiNaturalIdLoader()Access to performing multi-value natural-id database selection.NaturalIdLoader<?>getNaturalIdLoader()Access to performing natural-id database selection.NaturalIdMappinggetNaturalIdMapping()default intgetNumberOfAttributeMappings()Get the number of attributes defined on this class and any supersdefault intgetNumberOfDeclaredAttributeMappings()Get the number of attributes defined on this class - do not access attributes defined on the superdefault intgetNumberOfFetchables()The number of fetchables in the containerdefault MappingTypegetPartMappingType()default StringgetPartName()default EntityRepresentationStrategygetRepresentationStrategy()default EntityMappingTypegetRootEntityDescriptor()default StringgetRootPathName()EntityRowIdMappinggetRowIdMapping()default StringgetSqlAliasStem()Get the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generateddefault SqmMultiTableInsertStrategygetSqmMultiTableInsertStrategy()default SqmMultiTableMutationStrategygetSqmMultiTableMutationStrategy()default Set<String>getSubclassEntityNames()StringgetSubclassForDiscriminatorValue(Object value)default intgetSubclassId()default Collection<EntityMappingType>getSubMappingTypes()default EntityMappingTypegetSuperMappingType()EntityVersionMappinggetVersionMapping()default booleanhasSubclasses()default booleanisAbstract()default booleanisAffectedByEnabledFetchProfiles(LoadQueryInfluencers influencers)default booleanisAffectedByEnabledFilters(LoadQueryInfluencers influencers)default booleanisAffectedByEntityGraph(LoadQueryInfluencers influencers)default booleanisTypeOrSuperType(EntityMappingType targetType)default booleanisTypeOrSuperType(ManagedMappingType targetType)default voidpruneForSubclasses(TableGroup tableGroup, Set<String> treatedEntityNames)Adapts the table group and its table reference as well as table reference joins in a way such that unnecessary tables or joins are omitted if possible, based on the given treated entity names.default voidvisitAttributeMappings(Consumer<? super AttributeMapping> action)Visit attributes defined on this class and any supersdefault voidvisitAttributeMappings(Consumer<? super AttributeMapping> action, EntityMappingType targetType)Visit the mappings, but limited to just attributes defined in the targetType or its super-type(s) if any.voidvisitConstraintOrderedTables(EntityMappingType.ConstraintOrderedTableConsumer consumer)voidvisitDeclaredAttributeMappings(Consumer<? super AttributeMapping> action)Visit attributes defined on this class - do not visit attributes defined on the supervoidvisitQuerySpaces(Consumer<String> querySpaceConsumer)voidvisitSubParts(Consumer<ModelPart> consumer, EntityMappingType targetType)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.default voidvisitSubTypeAttributeMappings(Consumer<? super AttributeMapping> action)Walk this type's attributes as well as its sub-type'sdefault voidvisitSuperTypeAttributeMappings(Consumer<? super AttributeMapping> action)Walk this type's attributes as well as its super-type's-
Methods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, getJdbcMappings
-
Methods inherited from interface org.hibernate.metamodel.mapping.EntityValuedModelPart
getEntityMappingType
-
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.ManagedMappingType
findAttributeMapping, forEachAttributeMapping, getValue, getValues, setValue, setValues
-
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asAttributeMapping, breakDownJdbcValues, forEachSelectable, forEachSelectable, getNavigableRole
-
Methods inherited from interface org.hibernate.metamodel.mapping.Queryable
findByPath, findSubTypesSubPart, resolveSubPart
-
Methods inherited from interface org.hibernate.sql.ast.tree.from.TableGroupProducer
containsTableReference
-
-
-
-
Method Detail
-
getEntityPersister
EntityPersister getEntityPersister()
Safety-net. todo (6.0) : do we really need to expose?
-
getContributor
default String getContributor()
-
getRepresentationStrategy
default EntityRepresentationStrategy getRepresentationStrategy()
-
getEntityName
String getEntityName()
-
findContainingEntityMapping
default EntityMappingType findContainingEntityMapping()
- Specified by:
findContainingEntityMappingin interfaceModelPart
-
getPartName
default String getPartName()
- Specified by:
getPartNamein interfaceModelPart
-
getRootPathName
default String getRootPathName()
- Specified by:
getRootPathNamein interfaceLoadable
-
getJavaType
default JavaType<?> getJavaType()
- Specified by:
getJavaTypein interfaceManagedMappingType- Specified by:
getJavaTypein interfaceModelPart
-
getPartMappingType
default MappingType getPartMappingType()
- Specified by:
getPartMappingTypein interfaceManagedMappingType- Specified by:
getPartMappingTypein interfaceModelPart
-
findSubPart
default ModelPart findSubPart(String name)
- Specified by:
findSubPartin interfaceEntityValuedModelPart
-
findSubPart
ModelPart findSubPart(String name, EntityMappingType targetType)
Description copied from interface:QueryableFor 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:
findSubPartin interfaceEntityValuedModelPart- Specified by:
findSubPartin interfaceQueryable
-
visitSubParts
void visitSubParts(Consumer<ModelPart> consumer, EntityMappingType targetType)
Description copied from interface:QueryableLikeQueryable.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:
visitSubPartsin interfaceEntityValuedModelPart- Specified by:
visitSubPartsin interfaceQueryable
-
createDomainResult
<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 interfaceEntityValuedModelPart- Specified by:
createDomainResultin interfaceModelPart
-
applySqlSelections
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 interfaceEntityValuedModelPart- Specified by:
applySqlSelectionsin interfaceModelPart
-
applySqlSelections
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 interfaceEntityValuedModelPart- Specified by:
applySqlSelectionsin interfaceModelPart
-
getJdbcTypeCount
default int getJdbcTypeCount()
Description copied from interface:BindableThe number of JDBC mappings- Specified by:
getJdbcTypeCountin interfaceBindable- Specified by:
getJdbcTypeCountin interfaceEntityValuedModelPart- Specified by:
getJdbcTypeCountin interfaceJdbcMappingContainer
-
forEachJdbcType
int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)Description copied from interface:JdbcMappingContainerVisit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcTypein interfaceEntityValuedModelPart- Specified by:
forEachJdbcTypein interfaceJdbcMappingContainer
-
disassemble
Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemblein interfaceBindable- Specified by:
disassemblein interfaceEntityValuedModelPart- See Also:
As an example, consider the following domain model: ````
-
forEachDisassembledJdbcValue
int forEachDisassembledJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session)
- Specified by:
forEachDisassembledJdbcValuein interfaceBindable- Specified by:
forEachDisassembledJdbcValuein interfaceEntityValuedModelPart
-
forEachJdbcValue
default int forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)
- Specified by:
forEachJdbcValuein interfaceBindable- Specified by:
forEachJdbcValuein interfaceEntityValuedModelPart
-
getSubclassId
default int getSubclassId()
-
hasSubclasses
default boolean hasSubclasses()
-
findDeclaredAttributeMapping
AttributeMapping findDeclaredAttributeMapping(String name)
-
getNumberOfDeclaredAttributeMappings
default int getNumberOfDeclaredAttributeMappings()
Get the number of attributes defined on this class - do not access attributes defined on the super
-
getDeclaredAttributeMappings
Collection<AttributeMapping> getDeclaredAttributeMappings()
Get access to the attributes defined on this class - do not access attributes defined on the super
-
visitDeclaredAttributeMappings
void visitDeclaredAttributeMappings(Consumer<? super AttributeMapping> action)
Visit attributes defined on this class - do not visit attributes defined on the super
-
getSuperMappingType
default EntityMappingType getSuperMappingType()
-
getSubMappingTypes
default Collection<EntityMappingType> getSubMappingTypes()
-
isTypeOrSuperType
default boolean isTypeOrSuperType(EntityMappingType targetType)
-
isTypeOrSuperType
default boolean isTypeOrSuperType(ManagedMappingType targetType)
-
getSqmMultiTableMutationStrategy
default SqmMultiTableMutationStrategy getSqmMultiTableMutationStrategy()
-
getSqmMultiTableInsertStrategy
default SqmMultiTableInsertStrategy getSqmMultiTableInsertStrategy()
-
getIdentifierMapping
EntityIdentifierMapping getIdentifierMapping()
-
getDiscriminatorMapping
EntityDiscriminatorMapping getDiscriminatorMapping()
-
getDiscriminatorValue
Object getDiscriminatorValue()
-
getVersionMapping
EntityVersionMapping getVersionMapping()
-
getNaturalIdMapping
NaturalIdMapping getNaturalIdMapping()
-
getRowIdMapping
EntityRowIdMapping getRowIdMapping()
-
visitAttributeMappings
default void visitAttributeMappings(Consumer<? super AttributeMapping> action, EntityMappingType targetType)
Visit the mappings, but limited to just attributes defined in the targetType or its super-type(s) if any.- "API Note:"
- Passing
nullindicates that subclasses should be included. This matches legacy non-TREAT behavior and meets the need for EntityGraph processing
-
visitSubTypeAttributeMappings
default void visitSubTypeAttributeMappings(Consumer<? super AttributeMapping> action)
Walk this type's attributes as well as its sub-type's
-
visitSuperTypeAttributeMappings
default void visitSuperTypeAttributeMappings(Consumer<? super AttributeMapping> action)
Walk this type's attributes as well as its super-type's
-
visitConstraintOrderedTables
void visitConstraintOrderedTables(EntityMappingType.ConstraintOrderedTableConsumer consumer)
-
getRootEntityDescriptor
default EntityMappingType getRootEntityDescriptor()
-
pruneForSubclasses
default void pruneForSubclasses(TableGroup tableGroup, Set<String> treatedEntityNames)
Adapts the table group and its table reference as well as table reference joins in a way such that unnecessary tables or joins are omitted if possible, based on the given treated entity names. The goal is to e.g. remove join inheritance "branches" or union selects that are impossible. Consider the following example:class BaseEntity {} class Sub1 extends BaseEntity {} class Sub1Sub1 extends Sub1 {} class Sub1Sub2 extends Sub1 {} class Sub2 extends BaseEntity {} class Sub2Sub1 extends Sub2 {} class Sub2Sub2 extends Sub2 {}If thetreatedEntityNamesonly containsSub1or any of its subtypes, this means thatSub2and all subtypes are impossible, thus the joins/selects for these types shall be omitted in the given table group.- Parameters:
tableGroup- The table group to prune subclass tables fortreatedEntityNames- The entity names for which path usages were registered
-
isAbstract
default boolean isAbstract()
-
visitAttributeMappings
default void visitAttributeMappings(Consumer<? super AttributeMapping> action)
Description copied from interface:ManagedMappingTypeVisit attributes defined on this class and any supers- Specified by:
visitAttributeMappingsin interfaceManagedMappingType
-
extractConcreteTypeStateValues
@Deprecated(forRemoval=true) default Object[] extractConcreteTypeStateValues(Map<AttributeMapping,DomainResultAssembler> assemblerMapping, RowProcessingState rowProcessingState)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getNaturalIdLoader
NaturalIdLoader<?> getNaturalIdLoader()
Access to performing natural-id database selection. This is per-entity in the hierarchy
-
getMultiNaturalIdLoader
MultiNaturalIdLoader<?> getMultiNaturalIdLoader()
Access to performing multi-value natural-id database selection. This is per-entity in the hierarchy
-
isAffectedByEnabledFilters
default boolean isAffectedByEnabledFilters(LoadQueryInfluencers influencers)
- Specified by:
isAffectedByEnabledFiltersin interfaceLoadable
-
isAffectedByEntityGraph
default boolean isAffectedByEntityGraph(LoadQueryInfluencers influencers)
- Specified by:
isAffectedByEntityGraphin interfaceLoadable
-
isAffectedByEnabledFetchProfiles
default boolean isAffectedByEnabledFetchProfiles(LoadQueryInfluencers influencers)
- Specified by:
isAffectedByEnabledFetchProfilesin interfaceLoadable
-
createRootTableGroup
default TableGroup createRootTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAstCreationState creationState, SqlAstCreationContext creationContext)
Description copied from interface:RootTableGroupProducerCreate a root TableGroup as defined by this producer- Specified by:
createRootTableGroupin interfaceRootTableGroupProducer
-
createRootTableGroup
default TableGroup createRootTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAliasBase sqlAliasBase, SqlExpressionResolver expressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext)
- Specified by:
createRootTableGroupin interfaceRootTableGroupProducer
-
createPrimaryTableReference
default TableReference createPrimaryTableReference(SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
-
createTableReferenceJoin
default TableReferenceJoin createTableReferenceJoin(String joinTableExpression, SqlAliasBase sqlAliasBase, TableReference lhs, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
-
getNumberOfAttributeMappings
default int getNumberOfAttributeMappings()
Description copied from interface:ManagedMappingTypeGet the number of attributes defined on this class and any supers- Specified by:
getNumberOfAttributeMappingsin interfaceManagedMappingType
-
getAttributeMappings
default List<AttributeMapping> getAttributeMappings()
Description copied from interface:ManagedMappingTypeGet access to the attributes defined on this class and any supers- Specified by:
getAttributeMappingsin interfaceManagedMappingType
-
getAttributeMapping
default AttributeMapping getAttributeMapping(int position)
Description copied from interface:ManagedMappingTypeRetrieve an attribute by its contributor position- Specified by:
getAttributeMappingin interfaceManagedMappingType
-
getMappedJavaType
default JavaType getMappedJavaType()
- Specified by:
getMappedJavaTypein interfaceMappingType
-
getSqlAliasStem
default String getSqlAliasStem()
Description copied from interface:TableGroupProducerGet the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generated Note that this is a metadata-ive value. It is only ever used internal to the producer producing its TableGroup.- Specified by:
getSqlAliasStemin interfaceTableGroupProducer- See Also:
SqlAliasBaseManager.createSqlAliasBase(java.lang.String)
-
getNumberOfFetchables
default int getNumberOfFetchables()
Description copied from interface:FetchableContainerThe number of fetchables in the container- Specified by:
getNumberOfFetchablesin interfaceFetchableContainer
-
getFetchable
default Fetchable getFetchable(int position)
- Specified by:
getFetchablein interfaceFetchableContainer
-
applyDiscriminator
default void applyDiscriminator(Consumer<Predicate> predicateConsumer, String alias, TableGroup tableGroup, SqlAstCreationState creationState)
- Specified by:
applyDiscriminatorin interfaceDiscriminatable
-
applyFilterRestrictions
default void applyFilterRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, SqlAstCreationState creationState)
Description copied from interface:FilterRestrictableApplies just theFiltervalues enabled for the associated entity- Specified by:
applyFilterRestrictionsin interfaceFilterRestrictable
-
applyBaseRestrictions
default void applyBaseRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, Set<String> treatAsDeclarations, SqlAstCreationState creationState)
Description copied from interface:RestrictableApplies the base set of restrictions. The impact varies based on Restrictable type - some apply restrictions for filter, where and/or discriminator- Specified by:
applyBaseRestrictionsin interfaceRestrictable
-
applyWhereRestrictions
default void applyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState)
Description copied from interface:WhereRestrictableApply theWhererestrictions- Specified by:
applyWhereRestrictionsin interfaceWhereRestrictable
-
-