Package org.hibernate.metamodel.mapping
Interface EntityMappingType
- All Superinterfaces:
Bindable
,Discriminable
,EntityValuedModelPart
,FetchableContainer
,FilterRestrictable
,JdbcMappingContainer
,Loadable
,ManagedMappingType
,MappingModelExpressible
,MappingType
,ModelPart
,ModelPartContainer
,Restrictable
,RootTableGroupProducer
,SoftDeletableModelPart
,TableGroupProducer
,WhereRestrictable
- All Known Subinterfaces:
EntityPersister
,InFlightEntityMappingType
- All Known Implementing Classes:
AbstractEntityPersister
,AnonymousTupleEntityValuedModelPart
,JoinedSubclassEntityPersister
,MockEntityPersister
,ProcessorSessionFactory.EntityPersister
,SingleTableEntityPersister
,UnionSubclassEntityPersister
public interface EntityMappingType
extends ManagedMappingType, EntityValuedModelPart, Loadable, Restrictable, Discriminable, SoftDeletableModelPart
Mapping of an entity
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
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 -
Method Summary
Modifier and TypeMethodDescriptiondefault void
applyBaseRestrictions
(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String, Filter> enabledFilters, boolean onlyApplyLoadByKeyFilters, Set<String> treatAsDeclarations, SqlAstCreationState creationState) Applies the base set of restrictions.default void
applyDiscriminator
(Consumer<Predicate> predicateConsumer, String alias, TableGroup tableGroup, SqlAstCreationState creationState) Apply the discriminator as a predicate via thepredicateConsumer
default void
applyFilterRestrictions
(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String, Filter> enabledFilters, boolean onlyApplyLoadByKeyFilters, SqlAstCreationState creationState) Applies just theFilter
values enabled for the associated entitydefault void
applyWhereRestrictions
(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState) Apply theSQLRestriction
restrictionsdefault EntityMappingType
default TableReference
createPrimaryTableReference
(SqlAliasBase sqlAliasBase, SqlAstCreationState creationState) default TableGroup
createRootTableGroup
(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, SqlAliasBase explicitSqlAliasBase, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAstCreationState creationState) Create a root TableGroup as defined by this producerdefault TableReferenceJoin
createTableReferenceJoin
(String joinTableExpression, SqlAliasBase sqlAliasBase, TableReference lhs, SqlAstCreationState creationState) 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
Find an attribute-mapping, declared on this entity mapping (not super or subs), by namedefault ModelPart
findSubPart
(String name) default ModelPart
findSubTypesSubPart
(String name, EntityMappingType treatTargetType) default void
forEachAttributeMapping
(Consumer<? super AttributeMapping> action) Visit each attribute mappingdefault AttributeMapping
getAttributeMapping
(int position) Retrieve an attribute mapping by position, relative to all attributesdefault AttributeMappingsList
The attributes mapping for this entity, including those declared on supertype mappingsdefault String
Deprecated.Get access to the attributes defined on this class - do not access attributes defined on the superMapping details for the entity's discriminator.default String
The discriminator value which indicates this entity mappingThe entity name.Safety-net.default Fetchable
getFetchable
(int position) Mapping details for the entity's identifier.default EntityIdentifierMapping
Mapping details for the entity's identifier.Details for the table that defines the identifier column(s) for an entity hierarchy.default String
default JavaType<?>
The Java type for this part.default int
The number of JDBC mappingsdefault JavaType<?>
The descriptor descriptor for the mapped Java typedefault String
Get the name of the entity that is the "super class" for this entityDetails for the table this entity maps.Access to performing multi-value natural-id database selection.Access to performing natural-id database selection.The mapping for the natural-id of the entity, if one is defineddefault int
The total number of attributes for this entity, including those declared on supertype mappingsdefault int
Get the number of attributes defined on this entity mapping - do not access attributes defined on the superdefault int
The number of fetchables in the containerdefault MappingType
The type for this part.default String
The local part name, which is generally the unqualified role namedefault EntityRepresentationStrategy
Describes how the entity is represented in the application's domain model.default EntityMappingType
default String
The name for this loadable, for use as the root when generating relative pathsThe mapping for the row-id of the entity, if one is defined.default SoftDeleteMapping
Mapping for soft-delete support, ornull
if soft-delete not defineddefault TableDetails
default String
Get the "stem" used as the base for generating SQL table aliases for table references that are part of the TableGroup being generateddefault SqmMultiTableInsertStrategy
default SqmMultiTableMutationStrategy
default int
A value that uniquely identifies an entity mapping relative to its inheritance hierarchydefault Collection<EntityMappingType>
Retrieve mappings for all subtypesdefault EntityMappingType
The mapping for the entity which is the supertype for this entity mapping.Mapping details for the entity's version when using the version strategy.default boolean
Whether this entity mapping has any subtype mappingsdefault boolean
Does this restrictable have a where restriction?default boolean
Whether this entity is defined as abstract using the Javaabstract
keyworddefault boolean
isAffectedByEnabledFetchProfiles
(LoadQueryInfluencers influencers) Whether any of the LoadQueryInfluencers.getEnabledFetchProfileNames() apply to this loadabledefault boolean
isAffectedByEnabledFilters
(LoadQueryInfluencers influencers, boolean onlyApplyForLoadByKeyFilters) Whether any of the "influencers" affect this loadable.default boolean
isAffectedByEntityGraph
(LoadQueryInfluencers influencers) Whether the effective entity-graph applies to this loadabledefault boolean
Returnstrue
if this entity type's hierarchy is configured to return concrete-typed proxies.boolean
Deprecated.No longer supporteddefault boolean
isTypeOrSuperType
(EntityMappingType targetType) Whether the passed entity mapping is the same as or is a supertype of this entity mappingdefault boolean
isTypeOrSuperType
(ManagedMappingType targetType) Whether the passed mapping is (1) an entity mapping and (2) the same as or a supertype of this entity mappingloadByUniqueKey
(String propertyName, Object uniqueKey, SharedSessionContractImplementor session) Load an instance of the persistent class, by a unique key other than the primary key.default OptimisticLockStyle
The type of optimistic locking, if any, defined for this entity mappingdefault void
pruneForSubclasses
(TableGroup tableGroup, Map<String, EntityNameUse> entityNameUses) 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 EntityMappingType
If this entity is configured to return concrete-typed proxies, this method queries the entity table(s) do determine the concrete entity type associated with the provided id and returns its persister.default void
visitAttributeMappings
(Consumer<? super AttributeMapping> action) Visit the mappings, but limited to just attributes defined in the targetType or its super-type(s) if any.void
void
visitDeclaredAttributeMappings
(Consumer<? super AttributeMapping> action) Visit attributes defined on this class - do not visit attributes defined on the supervoid
visitQuerySpaces
(Consumer<String> querySpaceConsumer) Visit each "query space" for the mapped entity.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'sMethods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue
Methods inherited from interface org.hibernate.metamodel.mapping.EntityValuedModelPart
addToCacheKey, applySqlSelections, applySqlSelections, createDomainResult, disassemble, findSubPart, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachSubPart, getEntityMappingType, visitSubParts
Methods inherited from interface org.hibernate.sql.results.graph.FetchableContainer
getKeyFetchable, getNumberOfFetchableKeys, getNumberOfKeyFetchables, getSelectableIndex, visitFetchables, visitFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitKeyFetchables
Methods inherited from interface org.hibernate.metamodel.mapping.FilterRestrictable
applyFilterRestrictions
Methods inherited from interface org.hibernate.metamodel.mapping.JdbcMappingContainer
getJdbcMapping, getSingleJdbcMapping
Methods inherited from interface org.hibernate.loader.ast.spi.Loadable
getBatchSize, isAffectedByEnabledFilters, isAffectedByInfluencers, isAffectedByInfluencers, isNotAffectedByInfluencers
Methods inherited from interface org.hibernate.metamodel.mapping.ManagedMappingType
anyRequiresAggregateColumnWriter, findAttributeMapping, forEachAttributeMapping, getValue, getValues, hasPartitionedSelectionMapping, isAffectedByEnabledFilters, setValue, setValues
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asAttributeMapping, asBasicValuedModelPart, breakDownJdbcValues, breakDownJdbcValues, decompose, decompose, forEachSelectable, forEachSelectable, getNavigableRole, isEntityIdentifierMapping, isVirtual
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPartContainer
findByPath, findByPath, forEachSubPart
Methods inherited from interface org.hibernate.metamodel.mapping.Restrictable
applyBaseRestrictions
Methods inherited from interface org.hibernate.sql.ast.tree.from.TableGroupProducer
containsTableReference
-
Method Details
-
getEntityName
String getEntityName()The entity name. For most entities, this will be the fully-qualified name of the entity class. The alternative is an explicit entity-name which takes precedence if provided- API Note:
- Different from
Entity.name()
, which is just a glorified SQM "import" name
-
getRepresentationStrategy
Describes how the entity is represented in the application's domain model. -
getMappedTableDetails
TableDetails getMappedTableDetails()Details for the table this entity maps. Generally this is the same asgetIdentifierTableDetails()
, though may be different for subtypes in joined andunion inheritance hierarchies- See Also:
-
getIdentifierTableDetails
TableDetails getIdentifierTableDetails()Details for the table that defines the identifier column(s) for an entity hierarchy. -
findContainingEntityMapping
- Specified by:
findContainingEntityMapping
in interfaceModelPart
-
getJavaType
Description copied from interface:ModelPart
The Java type for this part. Generally equivalent toMappingType.getMappedJavaType()
relative toModelPart.getPartMappingType()
- Specified by:
getJavaType
in interfaceManagedMappingType
- Specified by:
getJavaType
in interfaceModelPart
-
asEntityMappingType
- Specified by:
asEntityMappingType
in interfaceModelPart
-
getPartMappingType
Description copied from interface:ModelPart
The type for this part.- Specified by:
getPartMappingType
in interfaceManagedMappingType
- Specified by:
getPartMappingType
in interfaceModelPart
-
visitQuerySpaces
Visit each "query space" for the mapped entity.- API Note:
- "Query space" is simply the table expressions to which the entity is mapped; the name is historical.
-
findSubPart
- Specified by:
findSubPart
in interfaceEntityValuedModelPart
-
findSubTypesSubPart
-
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
-
isAbstract
default boolean isAbstract()Whether this entity is defined as abstract using the Javaabstract
keyword -
hasSubclasses
default boolean hasSubclasses()Whether this entity mapping has any subtype mappings -
getSuperMappingType
The mapping for the entity which is the supertype for this entity mapping.- Returns:
- The supertype mapping, or
null
if there is no supertype - API Note:
- This need not be the direct superclass of the entity as it is driven by mapping.
-
getMappedSuperclass
Get the name of the entity that is the "super class" for this entity- See Also:
-
getSubMappingTypes
Retrieve mappings for all subtypes -
isTypeOrSuperType
Whether the passed entity mapping is the same as or is a supertype of this entity mapping -
isTypeOrSuperType
Whether the passed mapping is (1) an entity mapping and (2) the same as or a supertype of this entity mapping- See Also:
-
getSubclassId
default int getSubclassId()A value that uniquely identifies an entity mapping relative to its inheritance hierarchy -
getSubclassEntityNames
-
isExplicitPolymorphism
Deprecated.No longer supportedIs this class explicit polymorphism only? -
getDiscriminatorValue
Object getDiscriminatorValue()The discriminator value which indicates this entity mapping -
getDiscriminatorSQLValue
-
getRootEntityDescriptor
-
pruneForSubclasses
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 the
treatedEntityNames
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 forentityNameUses
- The entity names under which a table group was used.
-
getIdentifierMapping
EntityIdentifierMapping getIdentifierMapping()Mapping details for the entity's identifier. This is shared across all entity mappings within an inheritance hierarchy. -
getIdentifierMappingForJoin
Mapping details for the entity's identifier. This is shared across all entity mappings within an inheritance hierarchy. -
getDiscriminatorMapping
EntityDiscriminatorMapping getDiscriminatorMapping()Mapping details for the entity's discriminator. This is shared across all entity mappings within an inheritance hierarchy.- Specified by:
getDiscriminatorMapping
in interfaceDiscriminable
-
isConcreteProxy
Returnstrue
if this entity type's hierarchy is configured to return concrete-typed proxies.- Since:
- 6.6
- See Also:
-
getVersionMapping
EntityVersionMapping getVersionMapping()Mapping details for the entity's version when using the version strategy. This is shared across all entity mappings within an inheritance hierarchy.- Returns:
- The version mapping, or null if the entity is (1) defined
with a strategy other than
OptimisticLockStyle.VERSION
or (2) defined without optimistic locking - See Also:
-
optimisticLockStyle
The type of optimistic locking, if any, defined for this entity mapping -
getNaturalIdMapping
NaturalIdMapping getNaturalIdMapping()The mapping for the natural-id of the entity, if one is defined -
getRowIdMapping
EntityRowIdMapping getRowIdMapping()The mapping for the row-id of the entity, if one is defined. -
getSoftDeleteMapping
Mapping for soft-delete support, ornull
if soft-delete not defined- Specified by:
getSoftDeleteMapping
in interfaceSoftDeletableModelPart
-
getSoftDeleteTableDetails
- Specified by:
getSoftDeleteTableDetails
in interfaceSoftDeletableModelPart
-
getNumberOfAttributeMappings
default int getNumberOfAttributeMappings()The total number of attributes for this entity, including those declared on supertype mappings- Specified by:
getNumberOfAttributeMappings
in interfaceManagedMappingType
-
getAttributeMappings
The attributes mapping for this entity, including those declared on supertype mappings- Specified by:
getAttributeMappings
in interfaceManagedMappingType
-
forEachAttributeMapping
Visit each attribute mapping- Specified by:
forEachAttributeMapping
in interfaceManagedMappingType
- See Also:
-
getAttributeMapping
Retrieve an attribute mapping by position, relative to all attributes- Specified by:
getAttributeMapping
in interfaceManagedMappingType
-
findDeclaredAttributeMapping
Find an attribute-mapping, declared on this entity mapping (not super or subs), by name -
getNumberOfDeclaredAttributeMappings
default int getNumberOfDeclaredAttributeMappings()Get the number of attributes defined on this entity mapping - do not access attributes defined on the super -
getDeclaredAttributeMappings
AttributeMappingsMap getDeclaredAttributeMappings()Get access to the attributes defined on this class - do not access attributes defined on the super -
visitDeclaredAttributeMappings
Visit attributes defined on this class - do not visit attributes defined on the super -
visitAttributeMappings
Visit the mappings, but limited to just attributes defined in the targetType or its super-type(s) if any. -
visitSubTypeAttributeMappings
Walk this type's attributes as well as its sub-type's -
visitSuperTypeAttributeMappings
Walk this type's attributes as well as its super-type's -
visitConstraintOrderedTables
-
getImportedName
-
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, boolean onlyApplyForLoadByKeyFilters) Description copied from interface:Loadable
Whether any of the "influencers" affect this loadable.- Specified by:
isAffectedByEnabledFilters
in interfaceLoadable
-
isAffectedByEntityGraph
Description copied from interface:Loadable
Whether the effective entity-graph applies to this loadable- Specified by:
isAffectedByEntityGraph
in interfaceLoadable
-
isAffectedByEnabledFetchProfiles
Description copied from interface:Loadable
Whether any of the LoadQueryInfluencers.getEnabledFetchProfileNames() apply to this loadable- Specified by:
isAffectedByEnabledFetchProfiles
in interfaceLoadable
-
getSqmMultiTableMutationStrategy
-
getSqmMultiTableInsertStrategy
-
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 generatedNote 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:
-
createPrimaryTableReference
default TableReference createPrimaryTableReference(SqlAliasBase sqlAliasBase, SqlAstCreationState creationState) -
createTableReferenceJoin
default TableReferenceJoin createTableReferenceJoin(String joinTableExpression, SqlAliasBase sqlAliasBase, TableReference lhs, SqlAstCreationState creationState) -
getMappedJavaType
Description copied from interface:MappingType
The descriptor descriptor for the mapped Java type- Specified by:
getMappedJavaType
in interfaceMappingType
-
getNumberOfFetchables
default int getNumberOfFetchables()Description copied from interface:FetchableContainer
The number of fetchables in the container- Specified by:
getNumberOfFetchables
in interfaceFetchableContainer
-
getFetchable
- Specified by:
getFetchable
in interfaceFetchableContainer
-
applyDiscriminator
default void applyDiscriminator(Consumer<Predicate> predicateConsumer, String alias, TableGroup tableGroup, SqlAstCreationState creationState) Description copied from interface:Discriminable
Apply the discriminator as a predicate via thepredicateConsumer
- Specified by:
applyDiscriminator
in interfaceDiscriminable
-
applyFilterRestrictions
default void applyFilterRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, Map<String, Filter> enabledFilters, boolean onlyApplyLoadByKeyFilters, 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, boolean onlyApplyLoadByKeyFilters, Set<String> treatAsDeclarations, SqlAstCreationState creationState) Description copied from interface:Restrictable
Applies the base set of restrictions.- Specified by:
applyBaseRestrictions
in interfaceRestrictable
-
hasWhereRestrictions
default boolean hasWhereRestrictions()Description copied from interface:WhereRestrictable
Does this restrictable have a where restriction?- Specified by:
hasWhereRestrictions
in interfaceWhereRestrictable
-
applyWhereRestrictions
default void applyWhereRestrictions(Consumer<Predicate> predicateConsumer, TableGroup tableGroup, boolean useQualifier, SqlAstCreationState creationState) Description copied from interface:WhereRestrictable
Apply theSQLRestriction
restrictions- Specified by:
applyWhereRestrictions
in interfaceWhereRestrictable
-
getEntityPersister
Safety-net. -
getContributor
Deprecated. -
getPartName
Description copied from interface:ModelPart
The local part name, which is generally the unqualified role name- Specified by:
getPartName
in interfaceModelPart
-
getRootPathName
Description copied from interface:Loadable
The name for this loadable, for use as the root when generating relative paths- Specified by:
getRootPathName
in interfaceLoadable
-
Contributable.getContributor()