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
,InFlightEntityMappingType
,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 interface
EntityMappingType.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 void
applyBaseRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, Set<String> treatAsDeclarations, SqlAstCreationState creationState)
Applies the base set of restrictions.default void
applyDiscriminator(Consumer<Predicate> predicateConsumer, String alias, TableGroup tableGroup, SqlAstCreationState creationState)
default void
applyFilterRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, SqlAstCreationState creationState)
Applies just theFilter
values enabled for the associated entityvoid
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.default void
applyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState)
Apply theWhere
restrictions<T> DomainResult<T>
createDomainResult(NavigablePath navigablePath, TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState)
Create a DomainResult for a specific reference to this ModelPart.default TableReference
createPrimaryTableReference(SqlAliasBase sqlAliasBase, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
default TableGroup
createRootTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAliasBase sqlAliasBase, SqlExpressionResolver expressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext)
default TableGroup
createRootTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAstCreationState creationState, SqlAstCreationContext creationContext)
Create a root TableGroup as defined by this producerdefault TableReferenceJoin
createTableReferenceJoin(String joinTableExpression, SqlAliasBase sqlAliasBase, TableReference lhs, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext)
Object
disassemble(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 EntityMappingType
findContainingEntityMapping()
AttributeMapping
findDeclaredAttributeMapping(String name)
default ModelPart
findSubPart(String name)
ModelPart
findSubPart(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.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 offsetdefault int
forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)
default AttributeMapping
getAttributeMapping(int position)
Retrieve an attribute by its contributor positiondefault List<AttributeMapping>
getAttributeMappings()
Get access to the attributes defined on this class and any supersdefault String
getContributor()
Collection<AttributeMapping>
getDeclaredAttributeMappings()
Get access to the attributes defined on this class - do not access attributes defined on the superEntityDiscriminatorMapping
getDiscriminatorMapping()
Object
getDiscriminatorValue()
String
getEntityName()
EntityPersister
getEntityPersister()
Safety-net.default Fetchable
getFetchable(int position)
EntityIdentifierMapping
getIdentifierMapping()
default JavaType<?>
getJavaType()
default int
getJdbcTypeCount()
The number of JDBC mappingsdefault JavaType
getMappedJavaType()
MultiNaturalIdLoader<?>
getMultiNaturalIdLoader()
Access to performing multi-value natural-id database selection.NaturalIdLoader<?>
getNaturalIdLoader()
Access to performing natural-id database selection.NaturalIdMapping
getNaturalIdMapping()
default int
getNumberOfAttributeMappings()
Get the number of attributes defined on this class and any supersdefault int
getNumberOfDeclaredAttributeMappings()
Get the number of attributes defined on this class - do not access attributes defined on the superdefault int
getNumberOfFetchables()
The number of fetchables in the containerdefault MappingType
getPartMappingType()
default String
getPartName()
default EntityRepresentationStrategy
getRepresentationStrategy()
default EntityMappingType
getRootEntityDescriptor()
default String
getRootPathName()
EntityRowIdMapping
getRowIdMapping()
default String
getSqlAliasStem()
Get the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generateddefault SqmMultiTableInsertStrategy
getSqmMultiTableInsertStrategy()
default SqmMultiTableMutationStrategy
getSqmMultiTableMutationStrategy()
default Set<String>
getSubclassEntityNames()
String
getSubclassForDiscriminatorValue(Object value)
default int
getSubclassId()
default Collection<EntityMappingType>
getSubMappingTypes()
default EntityMappingType
getSuperMappingType()
EntityVersionMapping
getVersionMapping()
default boolean
hasSubclasses()
default boolean
isAbstract()
default boolean
isAffectedByEnabledFetchProfiles(LoadQueryInfluencers influencers)
default boolean
isAffectedByEnabledFilters(LoadQueryInfluencers influencers)
default boolean
isAffectedByEntityGraph(LoadQueryInfluencers influencers)
default boolean
isTypeOrSuperType(EntityMappingType targetType)
default boolean
isTypeOrSuperType(ManagedMappingType targetType)
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.default void
visitAttributeMappings(Consumer<? super AttributeMapping> action)
Visit attributes defined on this class and any supersdefault 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.void
visitConstraintOrderedTables(EntityMappingType.ConstraintOrderedTableConsumer consumer)
void
visitDeclaredAttributeMappings(Consumer<? super AttributeMapping> action)
Visit attributes defined on this class - do not visit attributes defined on the supervoid
visitQuerySpaces(Consumer<String> querySpaceConsumer)
void
visitSubParts(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 void
visitSubTypeAttributeMappings(Consumer<? super AttributeMapping> action)
Walk this type's attributes as well as its sub-type'sdefault void
visitSuperTypeAttributeMappings(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:
findContainingEntityMapping
in interfaceModelPart
-
getPartName
default String getPartName()
- Specified by:
getPartName
in interfaceModelPart
-
getRootPathName
default String getRootPathName()
- Specified by:
getRootPathName
in interfaceLoadable
-
getJavaType
default JavaType<?> getJavaType()
- Specified by:
getJavaType
in interfaceManagedMappingType
- Specified by:
getJavaType
in interfaceModelPart
-
getPartMappingType
default MappingType getPartMappingType()
- Specified by:
getPartMappingType
in interfaceManagedMappingType
- Specified by:
getPartMappingType
in interfaceModelPart
-
findSubPart
default ModelPart findSubPart(String name)
- Specified by:
findSubPart
in interfaceEntityValuedModelPart
-
findSubPart
ModelPart findSubPart(String name, EntityMappingType targetType)
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 interfaceEntityValuedModelPart
- Specified by:
findSubPart
in interfaceQueryable
-
visitSubParts
void visitSubParts(Consumer<ModelPart> consumer, EntityMappingType targetType)
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 interfaceEntityValuedModelPart
- Specified by:
visitSubParts
in interfaceQueryable
-
createDomainResult
<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 interfaceEntityValuedModelPart
- Specified by:
createDomainResult
in interfaceModelPart
-
applySqlSelections
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 interfaceEntityValuedModelPart
- Specified by:
applySqlSelections
in interfaceModelPart
-
applySqlSelections
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 interfaceEntityValuedModelPart
- Specified by:
applySqlSelections
in interfaceModelPart
-
getJdbcTypeCount
default int getJdbcTypeCount()
Description copied from interface:Bindable
The number of JDBC mappings- Specified by:
getJdbcTypeCount
in interfaceBindable
- Specified by:
getJdbcTypeCount
in interfaceEntityValuedModelPart
- Specified by:
getJdbcTypeCount
in interfaceJdbcMappingContainer
-
forEachJdbcType
int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> action)
Description copied from interface:JdbcMappingContainer
Visit each JdbcMapping starting from the given offset- Specified by:
forEachJdbcType
in interfaceEntityValuedModelPart
- Specified by:
forEachJdbcType
in interfaceJdbcMappingContainer
-
disassemble
Object disassemble(Object value, SharedSessionContractImplementor session)
- Specified by:
disassemble
in interfaceBindable
- Specified by:
disassemble
in 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:
forEachDisassembledJdbcValue
in interfaceBindable
- Specified by:
forEachDisassembledJdbcValue
in interfaceEntityValuedModelPart
-
forEachJdbcValue
default int forEachJdbcValue(Object value, Clause clause, int offset, Bindable.JdbcValuesConsumer consumer, SharedSessionContractImplementor session)
- Specified by:
forEachJdbcValue
in interfaceBindable
- Specified by:
forEachJdbcValue
in 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.
-
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 thetreatedEntityNames
only containsSub1
or any of its subtypes, this means thatSub2
and 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:ManagedMappingType
Visit attributes defined on this class and any supers- Specified by:
visitAttributeMappings
in 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:
isAffectedByEnabledFilters
in interfaceLoadable
-
isAffectedByEntityGraph
default boolean isAffectedByEntityGraph(LoadQueryInfluencers influencers)
- Specified by:
isAffectedByEntityGraph
in interfaceLoadable
-
isAffectedByEnabledFetchProfiles
default boolean isAffectedByEnabledFetchProfiles(LoadQueryInfluencers influencers)
- Specified by:
isAffectedByEnabledFetchProfiles
in interfaceLoadable
-
createRootTableGroup
default TableGroup createRootTableGroup(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAstCreationState creationState, SqlAstCreationContext creationContext)
Description copied from interface:RootTableGroupProducer
Create a root TableGroup as defined by this producer- Specified by:
createRootTableGroup
in 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:
createRootTableGroup
in 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:ManagedMappingType
Get the number of attributes defined on this class and any supers- Specified by:
getNumberOfAttributeMappings
in interfaceManagedMappingType
-
getAttributeMappings
default List<AttributeMapping> getAttributeMappings()
Description copied from interface:ManagedMappingType
Get access to the attributes defined on this class and any supers- Specified by:
getAttributeMappings
in interfaceManagedMappingType
-
getAttributeMapping
default AttributeMapping getAttributeMapping(int position)
Description copied from interface:ManagedMappingType
Retrieve an attribute by its contributor position- Specified by:
getAttributeMapping
in interfaceManagedMappingType
-
getMappedJavaType
default JavaType getMappedJavaType()
- Specified by:
getMappedJavaType
in interfaceMappingType
-
getSqlAliasStem
default String getSqlAliasStem()
Description copied from interface:TableGroupProducer
Get 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:
getSqlAliasStem
in interfaceTableGroupProducer
- See Also:
SqlAliasBaseManager.createSqlAliasBase(java.lang.String)
-
getNumberOfFetchables
default int getNumberOfFetchables()
Description copied from interface:FetchableContainer
The number of fetchables in the container- Specified by:
getNumberOfFetchables
in interfaceFetchableContainer
-
getFetchable
default Fetchable getFetchable(int position)
- Specified by:
getFetchable
in interfaceFetchableContainer
-
applyDiscriminator
default void applyDiscriminator(Consumer<Predicate> predicateConsumer, String alias, TableGroup tableGroup, SqlAstCreationState creationState)
- Specified by:
applyDiscriminator
in interfaceDiscriminatable
-
applyFilterRestrictions
default void applyFilterRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String,Filter> enabledFilters, SqlAstCreationState creationState)
Description copied from interface:FilterRestrictable
Applies just theFilter
values enabled for the associated entity- Specified by:
applyFilterRestrictions
in 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:Restrictable
Applies the base set of restrictions. The impact varies based on Restrictable type - some apply restrictions for filter, where and/or discriminator- Specified by:
applyBaseRestrictions
in interfaceRestrictable
-
applyWhereRestrictions
default void applyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState)
Description copied from interface:WhereRestrictable
Apply theWhere
restrictions- Specified by:
applyWhereRestrictions
in interfaceWhereRestrictable
-
-