Class UnionSubclassEntityPersister
- All Implemented Interfaces:
LazyPropertyInitializer
,FetchProfileAffectee
,Loadable
,Bindable
,Discriminable
,EntityMappingType
,EntityValuedModelPart
,FilterRestrictable
,InFlightEntityMappingType
,JdbcMappingContainer
,ManagedMappingType
,MappingModelExpressible
,MappingType
,ModelPart
,ModelPartContainer
,Restrictable
,SoftDeletableModelPart
,WhereRestrictable
,EntityPersister
,Joinable
,EntityMutationTarget
,AttributeSource
,RootTableGroupProducer
,TableGroupProducer
,MutationTarget<EntityTableMapping>
,FetchableContainer
EntityPersister
implementing the
InheritanceType.TABLE_PER_CLASS
mapping strategy for an entity and its inheritance hierarchy.
This is implemented as a separate table for each concrete class, with all inherited attributes persisted as columns of that table.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.hibernate.persister.entity.AbstractEntityPersister
AbstractEntityPersister.CacheEntryHelper
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.EntityMappingType
EntityMappingType.ConstraintOrderedTableConsumer
Nested classes/interfaces inherited from interface org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer
LazyPropertyInitializer.InterceptorImplementor
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.ModelPart
ModelPart.JdbcValueBiConsumer<X,
Y>, ModelPart.JdbcValueConsumer -
Field Summary
Fields inherited from class org.hibernate.persister.entity.AbstractEntityPersister
accessOptimizer, batchSize, customSQLDelete, customSQLInsert, customSQLUpdate, declaredAttributeMappings, deleteCallable, deleteExpectations, ENTITY_CLASS, fullDiscriminatorSQLValues, insertCallable, insertExpectations, insertGeneratedProperties, ROWID_ALIAS, rowIdName, staticFetchableList, updateCallable, updateExpectations, updateGeneratedProperties, VERSION_COLUMN_ALIAS
Fields inherited from interface org.hibernate.persister.entity.EntityPersister
ENTITY_ID
Fields inherited from interface org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer
UNFETCHED_PROPERTY
-
Constructor Summary
ConstructorsConstructorDescriptionUnionSubclassEntityPersister
(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, RuntimeModelCreationContext creationContext) -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsTableReference
(String tableExpression) createPrimaryTableReference
(SqlAliasBase sqlAliasBase, SqlAstCreationState creationState) createRootTableGroup
(boolean canUseInnerJoins, NavigablePath navigablePath, String explicitSourceAlias, SqlAliasBase sqlAliasBase, Supplier<Consumer<Predicate>> additionalPredicateCollectorAccess, SqlAstCreationState creationState) Create a root TableGroup as defined by this producerprotected EntityDiscriminatorMapping
generateDiscriminatorMapping
(PersistentClass bootEntityDescriptor) protected String
generateSubquery
(Map<String, EntityNameUse> entityNameUses) protected String
generateSubquery
(PersistentClass model, Metadata mapping) The name of the table to use when performing mutations (INSERT,UPDATE,DELETE) for the given attributeString[][]
String[]
BasicType<?>
Get the discriminator typeThe discriminator value which indicates this entity mappinggetFilterAliasGenerator
(String rootAlias) Details for the table that defines the identifier column(s) for an entity hierarchy.String[]
getKeyColumns
(int j) Details for the table this entity maps.String[]
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class only.protected int[]
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class and its subclasses.Locks are always applied to the "root table".int
getSubclassPropertyTableNumber
(String propertyName) Warning: When there are duplicated property names in the subclasses of the class, this method may return the wrong table number for the duplicated subclass property.protected String[]
getSubclassTableKeyColumns
(int j) getSubclassTableName
(int j) protected String[]
int
The table to join to.getTableName
(int j) int
boolean
boolean
protected boolean
isClassOrSuperclassTable
(int j) protected boolean
isIdentifierTable
(String tableExpression) protected boolean
boolean
isPropertyOfTable
(int property, int j) boolean
isTableCascadeDeleteEnabled
(int j) boolean
physicalTableNameForMutation
(SelectableMapping selectableMapping) Unfortunately we cannot directly use `SelectableMapping#getContainingTableExpression()` as that blows up for attributes declared on super-type for union-subclass mappingsvoid
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.protected boolean
protected void
void
protected void
visitMutabilityOrderedTables
(org.hibernate.persister.entity.AbstractEntityPersister.MutabilityOrderedTableConsumer consumer) Visit details about each table for this entity, using "mutability ordering".Methods inherited from class org.hibernate.persister.entity.AbstractEntityPersister
addDiscriminatorToInsertGroup, addSoftDeleteToInsertGroup, afterInitialize, afterReassociate, applyBaseRestrictions, applyDiscriminator, applyFilterRestrictions, applySqlSelections, applySqlSelections, applyWhereRestrictions, buildCacheEntry, buildCacheEntryHelper, buildDeleteCoordinator, buildEmbeddedAttributeMapping, buildInsertCoordinator, buildMergeCoordinator, buildMultiIdLoader, buildPluralAttributeMapping, buildSingleIdEntityLoader, buildSingularAssociationAttributeMapping, buildTableMappings, buildUpdateCoordinator, canReadFromCache, canUseReferenceCacheEntries, canWriteToCache, countSubclassProperties, createDomainResult, createGeneratedValuesProcessor, createInsertDelegate, createProxy, createTableReferenceJoin, createUpdateDelegate, determineLoaderToUse, determineTableName, determineTableNumberForColumn, disassemble, findAttributeMapping, findDeclaredAttributeMapping, findDirty, findModified, findSubPart, findSubTypesSubPart, forceVersionIncrement, forceVersionIncrement, forEachAttributeMapping, forEachAttributeMapping, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachMutableTable, forEachMutableTableReverse, forEachSelectable, generateIdentifierMapping, generateJoinPredicate, generateLocker, generateNaturalIdMapping, generateNonEncapsulatedCompositeIdentifierMapping, generateNonIdAttributeMapping, generateSelectVersionString, generateTableAlias, generateTableReferenceJoin, generateVersionMapping, generateVersionMapping, getAttributeMapping, getAttributeMappings, getBatchSize, getBytecodeEnhancementMetadata, getCacheAccessStrategy, getCacheEntryStructure, getCollectionKey, getConcreteProxyClass, getCurrentVersion, getDatabaseSnapshot, getDeclaredAttributeMappings, getDeleteCoordinator, getDiscriminatorAlias, getDiscriminatorAlias, getDiscriminatorColumnName, getDiscriminatorColumnReaders, getDiscriminatorColumnReaderTemplate, getDiscriminatorFormulaTemplate, getDiscriminatorMapping, getEntityEntryFactory, getEntityMetamodel, getEntityName, getEntityNameByTableNameMap, getEntityPersister, getFactory, getFetchable, getFetchMode, getGenerator, getIdByUniqueKey, getIdentifier, getIdentifier, getIdentifierAliases, getIdentifierAliases, getIdentifierColumnNames, getIdentifierColumnReaders, getIdentifierColumnReaderTemplates, getIdentifierColumnSpan, getIdentifierDescriptor, getIdentifierGenerator, getIdentifierMapping, getIdentifierPropertyName, getIdentifierTableMapping, getIdentifierTableName, getIdentifierType, getIdentitySelectString, getInsertCoordinator, getInsertDelegate, getInsertGeneratedProperties, getInsertGeneratedValuesProcessor, getInstrumentationMetadata, getJdbcMapping, getJdbcTypeCount, getJpaEntityName, getKeyFetchable, getLazyLoadPlanByFetchGroup, getMappedClass, getMappedJavaType, getMappedSuperclass, getMergeCoordinator, getMultiNaturalIdLoader, getNaturalIdCacheAccessStrategy, getNaturalIdentifierProperties, getNaturalIdentifierSnapshot, getNaturalIdLoader, getNaturalIdMapping, getNavigableRole, getNonLazyPropertyUpdateability, getNumberOfAttributeMappings, getNumberOfDeclaredAttributeMappings, getNumberOfFetchableKeys, getNumberOfFetchables, getPartName, getPropertyAliases, getPropertyCascadeStyles, getPropertyCheckability, getPropertyColumnNames, getPropertyColumnNames, getPropertyIndex, getPropertyInsertability, getPropertyLaziness, getPropertyNames, getPropertyNullability, getPropertySpan, getPropertyType, getPropertyTypes, getPropertyUpdateability, getPropertyUpdateability, getPropertyValue, getPropertyValue, getPropertyValues, getPropertyValuesToInsert, getPropertyVersionability, getPrunedDiscriminatorPredicate, getRepresentationStrategy, getRootEntityName, getRootTableIdentifierColumnNames, getRootTableKeyColumnNames, getRowIdMapping, getSelectByUniqueKeyString, getSelectByUniqueKeyString, getSelectByUniqueKeyString, getSingleIdLoader, getSoftDeleteMapping, getSqlAliasStem, getSqlWhereStringTableExpression, getSqmMultiTableInsertStrategy, getSqmMultiTableMutationStrategy, getStateArrayInitialPosition, getStaticFetchableList, getSubclassColumnAliasClosure, getSubclassEntityPersister, getSubclassFormulaAliasClosure, getSubclassPropertyColumnAliases, getSubclassPropertyColumnNameClosure, getSubclassPropertyColumnNames, getSubclassPropertyColumnReaderClosure, getSubclassPropertyColumnReaderTemplateClosure, getSubclassPropertyFormulaTemplateClosure, getSubclassPropertyNameClosure, getSubclassPropertyType, getSubclassPropertyTypeClosure, getSubMappingTypes, getSuperMappingType, getTableId, getTableMapping, getTableMappings, getTableNameForColumn, getTableNames, getTargetPart, getTypeDiscriminatorMetadata, getUniqueKeyLoader, getUpdateCoordinator, getUpdateDelegate, getUpdateGeneratedProperties, getUpdateGeneratedValuesProcessor, getVersion, getVersionColumnName, getVersionedTableName, getVersionGenerator, getVersionMapping, getVersionProperty, getVersionSelectString, getVersionType, hasCache, hasCascadeDelete, hasCascades, hasCollectionNotReferencingPK, hasCollections, hasFilterForLoadByKey, hasFormulaProperties, hasIdentifierProperty, hasInsertGeneratedProperties, hasLazyProperties, hasMutableProperties, hasNaturalIdCache, hasNaturalIdentifier, hasOwnedCollections, hasPartitionedSelectionMapping, hasProxy, hasRowId, hasSubclasses, hasSubselectLoadableCollections, hasUninitializedLazyProperties, hasUpdateGeneratedProperties, hasWhereRestrictions, initializeEnhancedEntityUsedAsProxy, initializeLazyPropertiesFromCache, initializeLazyPropertiesFromDatastore, initializeLazyProperty, initializeLazyProperty, initializeLazyProperty, initInsertGeneratedProperties, initPropertyPaths, initSubclassPropertyAliasesMap, initUpdateGeneratedProperties, instantiate, interpretSqmMultiTableInsertStrategy, interpretSqmMultiTableStrategy, isAbstract, isAffectedByEnabledFetchProfiles, isAffectedByEnabledFilters, isAffectedByEntityGraph, isCacheInvalidationRequired, isClassOrSuperclassJoin, isConcreteProxy, isDiscriminatorFormula, isExplicitPolymorphism, isIdentifierAssignedByInsert, isInherited, isInstance, isInstrumented, isInverseTable, isLazyPropertiesCacheable, isMutable, isNullableSubclassTable, isNullableTable, isPropertySelectable, isSelectBeforeUpdateRequired, isSharedColumn, isSubclassEntityName, isSubclassTableIndicatedByTreatAsDeclarations, isTransient, isTypeOrSuperType, isVersioned, isVersionGeneratedBeforeExecution, isVersionGeneratedOnExecution, isVersionPropertyGenerated, linkToSession, linkWithSubType, linkWithSuperType, load, load, load, loadByUniqueKey, loadByUniqueKey, loadEntityIdByNaturalId, lock, lock, logStaticSQL, managesColumns, multiLoad, optimisticLockStyle, postConstruct, postInstantiate, prepareLoaders, prepareMappingModel, processInsertGeneratedProperties, processUpdateGeneratedProperties, registerAffectingFetchProfile, resetIdentifier, resolveAttributeIndexes, resolveConcreteProxyTypeForId, resolveDirtyAttributeIndexes, resolveDiscriminatorType, selectFragment, setIdentifier, setPropertyValue, setPropertyValues, shouldGetAllProperties, shouldInnerJoinSubclassTable, storeDiscriminatorInShallowQueryCacheLayout, substituteBrackets, toColumns, toString, uniqueKeyEntries, useShallowQueryCacheLayout, verifyHasNaturalId, visitAttributeMappings, visitDeclaredAttributeMappings, visitFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitSubParts, visitSubTypeAttributeMappings, visitSuperTypeAttributeMappings
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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.EntityMappingType
asEntityMappingType, extractConcreteTypeStateValues, findContainingEntityMapping, findSubPart, getContributor, getIdentifierMappingForJoin, getJavaType, getPartMappingType, getRootEntityDescriptor, getRootPathName, getSoftDeleteTableDetails, getSubclassEntityNames, getSubclassId, isTypeOrSuperType
Methods inherited from interface org.hibernate.persister.entity.mutation.EntityMutationTarget
getIdentityInsertDelegate, getMutationDelegate
Methods inherited from interface org.hibernate.persister.entity.EntityPersister
addToCacheKey, breakDownJdbcValues, canExtractIdOutOfEntity, delete, getEntityMappingType, getFilterAliasGenerator, getGeneratedProperties, getIdentifier, getImportedName, getSynchronizationSpaces, getSynchronizedQuerySpaces, getValue, getValues, getVersionJavaType, insert, insert, isBatchLoadable, load, merge, processInsertGeneratedProperties, processUpdateGeneratedProperties, setValue, setValues, update, visitQuerySpaces
Methods inherited from interface org.hibernate.metamodel.mapping.EntityValuedModelPart
forEachSubPart
Methods inherited from interface org.hibernate.sql.results.graph.FetchableContainer
getNumberOfKeyFetchables, getSelectableIndex, visitFetchables, visitKeyFetchables
Methods inherited from interface org.hibernate.metamodel.mapping.FilterRestrictable
applyFilterRestrictions
Methods inherited from interface org.hibernate.metamodel.mapping.JdbcMappingContainer
getSingleJdbcMapping
Methods inherited from interface org.hibernate.loader.ast.spi.Loadable
isAffectedByEnabledFilters, isAffectedByInfluencers, isAffectedByInfluencers, isNotAffectedByInfluencers
Methods inherited from interface org.hibernate.metamodel.mapping.ManagedMappingType
anyRequiresAggregateColumnWriter, isAffectedByEnabledFilters
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asAttributeMapping, asBasicValuedModelPart, breakDownJdbcValues, decompose, decompose, forEachSelectable, isEntityIdentifierMapping, isVirtual
Methods inherited from interface org.hibernate.metamodel.mapping.ModelPartContainer
findByPath, findByPath, forEachSubPart
Methods inherited from interface org.hibernate.sql.model.MutationTarget
getRolePath
Methods inherited from interface org.hibernate.metamodel.mapping.Restrictable
applyBaseRestrictions
-
Constructor Details
-
UnionSubclassEntityPersister
public UnionSubclassEntityPersister(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, RuntimeModelCreationContext creationContext) throws HibernateException - Throws:
HibernateException
-
-
Method Details
-
validateGenerator
protected void validateGenerator() -
containsTableReference
- Specified by:
containsTableReference
in interfaceTableGroupProducer
- Overrides:
containsTableReference
in classAbstractEntityPersister
-
createPrimaryTableReference
public UnionTableReference createPrimaryTableReference(SqlAliasBase sqlAliasBase, SqlAstCreationState creationState) - Specified by:
createPrimaryTableReference
in interfaceEntityMappingType
- Overrides:
createPrimaryTableReference
in classAbstractEntityPersister
-
needsDiscriminator
public boolean needsDiscriminator()- Specified by:
needsDiscriminator
in classAbstractEntityPersister
-
getQuerySpaces
Description copied from interface:EntityPersister
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class and its subclasses.Much like
EntityPersister.getPropertySpaces()
, except that here we include subclass entity spaces.- Specified by:
getQuerySpaces
in interfaceEntityPersister
- Overrides:
getQuerySpaces
in classAbstractEntityPersister
- Returns:
- The query spaces.
-
getRootTableName
Description copied from interface:EntityPersister
Locks are always applied to the "root table".- Specified by:
getRootTableName
in interfaceEntityPersister
- Overrides:
getRootTableName
in classAbstractEntityPersister
- Returns:
- The root table name
-
getTableName
Description copied from interface:EntityPersister
The table to join to. -
getDiscriminatorType
Description copied from interface:EntityPersister
Get the discriminator type- Specified by:
getDiscriminatorType
in interfaceEntityPersister
- Specified by:
getDiscriminatorType
in classAbstractEntityPersister
-
getSubclassByDiscriminatorValue
- Specified by:
getSubclassByDiscriminatorValue
in classAbstractEntityPersister
-
getMappedTableDetails
Description copied from interface:EntityMappingType
Details for the table this entity maps. Generally this is the same asEntityMappingType.getIdentifierTableDetails()
, though may be different for subtypes in joined andunion inheritance hierarchies -
getIdentifierTableDetails
Description copied from interface:EntityMappingType
Details for the table that defines the identifier column(s) for an entity hierarchy. -
getDiscriminatorValue
Description copied from interface:EntityMappingType
The discriminator value which indicates this entity mapping -
getDiscriminatorSQLValue
-
getPropertySpaces
Description copied from interface:EntityPersister
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class only.For most implementations, this returns the complete set of table names to which instances of the mapped entity are persisted (not accounting for superclass entity mappings).
- Returns:
- The property spaces.
-
shouldProcessSuperMapping
protected boolean shouldProcessSuperMapping()- Overrides:
shouldProcessSuperMapping
in classAbstractEntityPersister
-
hasDuplicateTables
public boolean hasDuplicateTables() -
getTableName
-
getKeyColumns
-
isTableCascadeDeleteEnabled
public boolean isTableCascadeDeleteEnabled(int j) - Specified by:
isTableCascadeDeleteEnabled
in classAbstractEntityPersister
-
isPropertyOfTable
public boolean isPropertyOfTable(int property, int j) - Specified by:
isPropertyOfTable
in classAbstractEntityPersister
-
getAttributeMutationTableName
Description copied from interface:EntityMutationTarget
The name of the table to use when performing mutations (INSERT,UPDATE,DELETE) for the given attribute -
getSubclassPropertyTableNumber
Description copied from class:AbstractEntityPersister
Warning: When there are duplicated property names in the subclasses of the class, this method may return the wrong table number for the duplicated subclass property. Note that SingleTableEntityPersister defines an overloaded form which takes the entity name.- Overrides:
getSubclassPropertyTableNumber
in classAbstractEntityPersister
-
physicalTableNameForMutation
Description copied from class:AbstractEntityPersister
Unfortunately we cannot directly use `SelectableMapping#getContainingTableExpression()` as that blows up for attributes declared on super-type for union-subclass mappings- Specified by:
physicalTableNameForMutation
in interfaceEntityMutationTarget
- Overrides:
physicalTableNameForMutation
in classAbstractEntityPersister
-
isIdentifierTable
- Specified by:
isIdentifierTable
in classAbstractEntityPersister
-
hasMultipleTables
public boolean hasMultipleTables()- Specified by:
hasMultipleTables
in interfaceEntityPersister
- Overrides:
hasMultipleTables
in classAbstractEntityPersister
-
pruneForSubclasses
Description copied from interface:EntityMappingType
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.
-
visitConstraintOrderedTables
-
visitMutabilityOrderedTables
protected void visitMutabilityOrderedTables(org.hibernate.persister.entity.AbstractEntityPersister.MutabilityOrderedTableConsumer consumer) Description copied from class:AbstractEntityPersister
Visit details about each table for this entity, using "mutability ordering". When inserting rows, the order we go through the tables to avoid foreign key problems among the entity's group of tables.Used while building the table mapping descriptors for each table.
- Specified by:
visitMutabilityOrderedTables
in classAbstractEntityPersister
- See Also:
-
isPhysicalDiscriminator
protected boolean isPhysicalDiscriminator()- Overrides:
isPhysicalDiscriminator
in classAbstractEntityPersister
-
generateDiscriminatorMapping
protected EntityDiscriminatorMapping generateDiscriminatorMapping(PersistentClass bootEntityDescriptor) - Overrides:
generateDiscriminatorMapping
in classAbstractEntityPersister
-
getTableSpan
public int getTableSpan() -
getPropertyTableNumbers
protected int[] getPropertyTableNumbers()- Specified by:
getPropertyTableNumbers
in classAbstractEntityPersister
-
generateSubquery
-
generateSubquery
-
getSubclassTableKeyColumns
- Specified by:
getSubclassTableKeyColumns
in classAbstractEntityPersister
-
getSubclassTableName
-
getSubclassTableNames
- Specified by:
getSubclassTableNames
in classAbstractEntityPersister
-
getSubclassTableSpan
public int getSubclassTableSpan() -
isClassOrSuperclassTable
protected boolean isClassOrSuperclassTable(int j) - Specified by:
isClassOrSuperclassTable
in classAbstractEntityPersister
-
getConstraintOrderedTableNameClosure
- Specified by:
getConstraintOrderedTableNameClosure
in classAbstractEntityPersister
-
getConstraintOrderedTableKeyColumnClosure
-
getFilterAliasGenerator
-