Class SingleTableEntityPersister
- 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 interface.
Implements the InheritanceType.SINGLE_TABLE
mapping strategy for an entity class and its inheritance hierarchy.
This is implemented as a single table for all classes of the hierarchy, with a discriminator column used to determine which concrete class a row represents.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.hibernate.persister.entity.AbstractEntityPersister
AbstractEntityPersister.CacheEntryHelper, AbstractEntityPersister.MutabilityOrderedTableConsumerNested 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.ConstraintOrderedTableConsumerNested classes/interfaces inherited from interface org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer
LazyPropertyInitializer.InterceptorImplementorNested 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_ALIASFields inherited from interface org.hibernate.persister.entity.EntityPersister
ENTITY_IDFields inherited from interface org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer
UNFETCHED_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionSingleTableEntityPersister(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, RuntimeModelCreationContext creationContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) 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[]String[]Deprecated, for removal: This API element is subject to removal in a future version.No longer used.protected String[]getSubclassTableKeyColumns(int j) getSubclassTableName(int j) protected String[]intThe table to join to.getTableName(int j) intbooleanbooleanprotected booleanisClassOrSuperclassJoin(int j) protected booleanisClassOrSuperclassTable(int j) protected booleanprotected booleanisIdentifierTable(String tableExpression) booleanisInverseTable(int j) protected booleanisNullableSubclassTable(int j) booleanisNullableTable(int j) booleanisPropertyOfTable(int property, int j) booleanisTableCascadeDeleteEnabled(int j) booleanvoidpruneForSubclasses(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.voidprotected voidVisit details about each table for this entity, using "mutability ordering".Methods inherited from class org.hibernate.persister.entity.AbstractEntityPersister
addSoftDeleteToInsertGroup, afterInitialize, afterReassociate, applyBaseRestrictions, applyDiscriminator, applyFilterRestrictions, applySqlSelections, applySqlSelections, applyWhereRestrictions, buildCacheEntry, buildCacheEntryHelper, buildDeleteCoordinator, buildEmbeddedAttributeMapping, buildInsertCoordinator, buildMergeCoordinator, buildMultiIdLoader, buildPluralAttributeMapping, buildSingleIdEntityLoader, buildSingularAssociationAttributeMapping, buildTableMappings, buildUpdateCoordinator, canReadFromCache, canUseReferenceCacheEntries, canWriteToCache, containsTableReference, countSubclassProperties, createDomainResult, createGeneratedValuesProcessor, createInsertDelegate, createPrimaryTableReference, createProxy, createRootTableGroup, createTableReferenceJoin, createUpdateDelegate, determineLoaderToUse, determineTableName, determineTableNumberForColumn, disassemble, findAttributeMapping, findDeclaredAttributeMapping, findDirty, findModified, findSubPart, findSubTypesSubPart, forceVersionIncrement, forceVersionIncrement, forEachAttributeMapping, forEachAttributeMapping, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachMutableTable, forEachMutableTableReverse, forEachSelectable, generateDiscriminatorMapping, generateIdentifierMapping, generateJoinPredicate, generateLocker, generateNaturalIdMapping, generateNonEncapsulatedCompositeIdentifierMapping, generateNonIdAttributeMapping, generateSelectVersionString, generateTableAlias, generateTableReferenceJoin, generateVersionMapping, generateVersionMapping, getAttributeMapping, getAttributeMappings, getBatchSize, getBytecodeEnhancementMetadata, getCacheAccessStrategy, getCacheEntryStructure, getCollectionKey, getConcreteProxyClass, getCurrentVersion, getDatabaseSnapshot, getDeclaredAttributeMappings, getDeleteCoordinator, getDiscriminatorAlias, getDiscriminatorDomainType, 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, getQuerySpaces, getRepresentationStrategy, getRootEntityName, getRootTableIdentifierColumnNames, getRootTableKeyColumnNames, getRootTableName, 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, getUniqueKeyLoader, getUpdateCoordinator, getUpdateDelegate, getUpdateGeneratedProperties, getUpdateGeneratedValuesProcessor, getVersion, getVersionColumnName, getVersionedTableName, getVersionGenerator, getVersionMapping, getVersionProperty, getVersionSelectString, getVersionType, hasCache, hasCascadeDelete, hasCascadePersist, hasCascades, hasCollectionNotReferencingPK, hasCollections, hasFilterForLoadByKey, hasFormulaProperties, hasIdentifierProperty, hasInsertGeneratedProperties, hasLazyProperties, hasMutableProperties, hasNaturalIdCache, hasNaturalIdentifier, hasOwnedCollections, hasPartitionedSelectionMapping, hasProxy, hasRowId, hasSubclasses, hasSubselectLoadableCollections, hasToOnes, hasUninitializedLazyProperties, hasUpdateGeneratedProperties, hasWhereRestrictions, initializeEnhancedEntityUsedAsProxy, initializeLazyPropertiesFromCache, initializeLazyPropertiesFromDatastore, initializeLazyProperty, initializeLazyProperty, initializeLazyProperty, initializeLazyProperty, initInsertGeneratedProperties, initPropertyPaths, initSubclassPropertyAliasesMap, initUpdateGeneratedProperties, instantiate, interpretSqmMultiTableInsertStrategy, interpretSqmMultiTableStrategy, isAbstract, isAffectedByEnabledFetchProfiles, isAffectedByEnabledFilters, isAffectedByEntityGraph, isCacheInvalidationRequired, isConcreteProxy, isExplicitPolymorphism, isIdentifierAssignedByInsert, isInherited, isInstance, isInstrumented, isLazyPropertiesCacheable, isMutable, isNonLazyPropertyName, isPhysicalDiscriminator, isPropertySelectable, isSelectBeforeUpdateRequired, isSharedColumn, isSubclassEntityName, isSubclassTableIndicatedByTreatAsDeclarations, isTransient, isTypeOrSuperType, isVersioned, isVersionGeneratedBeforeExecution, isVersionGeneratedOnExecution, isVersionPropertyGenerated, linkToSession, linkWithSubType, linkWithSuperType, load, load, load, loadByUniqueKey, loadByUniqueKey, loadEntityIdByNaturalId, lock, lock, lock, lock, logStaticSQL, managesColumns, multiLoad, multiLoad, optimisticLockStyle, physicalTableNameForMutation, postConstruct, postInstantiate, prepareLoaders, prepareMappingModel, processInsertGeneratedProperties, processUpdateGeneratedProperties, registerAffectingFetchProfile, resetIdentifier, resolveAttributeIndexes, resolveConcreteProxyTypeForId, resolveDirtyAttributeIndexes, selectFragment, setIdentifier, setPropertyValue, setPropertyValues, shouldGetAllProperties, shouldInnerJoinSubclassTable, shouldProcessSuperMapping, storeDiscriminatorInShallowQueryCacheLayout, substituteBrackets, toColumns, toString, uniqueKeyEntries, useShallowQueryCacheLayout, verifyHasNaturalId, visitAttributeMappings, visitDeclaredAttributeMappings, visitFetchables, visitFetchables, visitKeyFetchables, visitKeyFetchables, visitSubParts, visitSubTypeAttributeMappings, visitSuperTypeAttributeMappingsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcValue, forEachJdbcValue, forEachJdbcValueMethods inherited from interface org.hibernate.metamodel.mapping.EntityMappingType
asEntityMappingType, extractConcreteTypeStateValues, findContainingEntityMapping, findSubPart, getContributor, getIdentifierMappingForJoin, getJavaType, getPartMappingType, getRootEntityDescriptor, getRootPathName, getSoftDeleteTableDetails, getSubclassEntityNames, getSubclassId, isTypeOrSuperTypeMethods inherited from interface org.hibernate.persister.entity.mutation.EntityMutationTarget
getIdentityInsertDelegate, getMutationDelegateMethods inherited from interface org.hibernate.persister.entity.EntityPersister
addToCacheKey, breakDownJdbcValues, canExtractIdOutOfEntity, delete, getEntityMappingType, getFilterAliasGenerator, getGeneratedProperties, getIdentifier, getImportedName, getSynchronizationSpaces, getSynchronizedQuerySpaces, getTypeDiscriminatorMetadata, getValue, getValues, getVersionJavaType, insert, insert, isBatchLoadable, load, merge, processInsertGeneratedProperties, processUpdateGeneratedProperties, setValue, setValues, update, visitQuerySpacesMethods inherited from interface org.hibernate.metamodel.mapping.EntityValuedModelPart
forEachSubPartMethods inherited from interface org.hibernate.sql.results.graph.FetchableContainer
getNumberOfKeyFetchables, getSelectableIndex, visitFetchables, visitKeyFetchablesMethods inherited from interface org.hibernate.metamodel.mapping.FilterRestrictable
applyFilterRestrictionsMethods inherited from interface org.hibernate.metamodel.mapping.JdbcMappingContainer
getSingleJdbcMappingMethods inherited from interface org.hibernate.loader.ast.spi.Loadable
isAffectedByEnabledFilters, isAffectedByInfluencers, isAffectedByInfluencers, isNotAffectedByInfluencersMethods inherited from interface org.hibernate.metamodel.mapping.ManagedMappingType
anyRequiresAggregateColumnWriter, isAffectedByEnabledFiltersMethods inherited from interface org.hibernate.metamodel.mapping.ModelPart
areEqual, asAttributeMapping, asBasicValuedModelPart, breakDownJdbcValues, decompose, decompose, forEachSelectable, isEntityIdentifierMapping, isVirtualMethods inherited from interface org.hibernate.metamodel.mapping.ModelPartContainer
findByPath, findByPath, forEachSubPartMethods inherited from interface org.hibernate.sql.model.MutationTarget
getRolePathMethods inherited from interface org.hibernate.metamodel.mapping.Restrictable
applyBaseRestrictions
-
Constructor Details
-
SingleTableEntityPersister
public SingleTableEntityPersister(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, RuntimeModelCreationContext creationContext) throws HibernateException - Throws:
HibernateException
-
-
Method Details
-
isInverseTable
public boolean isInverseTable(int j) - Specified by:
isInverseTablein interfaceEntityPersister- Overrides:
isInverseTablein classAbstractEntityPersister
-
getDiscriminatorColumnName
- Specified by:
getDiscriminatorColumnNamein interfaceEntityPersister- Overrides:
getDiscriminatorColumnNamein classAbstractEntityPersister- Returns:
- the column name for the discriminator as specified in the mapping.
-
getDiscriminatorColumnReaders
- Overrides:
getDiscriminatorColumnReadersin classAbstractEntityPersister
-
getDiscriminatorColumnReaderTemplate
- Overrides:
getDiscriminatorColumnReaderTemplatein classAbstractEntityPersister
-
getDiscriminatorFormulaTemplate
- Overrides:
getDiscriminatorFormulaTemplatein classAbstractEntityPersister
-
getTableName
Description copied from interface:EntityPersisterThe table to join to. -
getDiscriminatorType
Description copied from interface:EntityPersisterGet the discriminator type- Specified by:
getDiscriminatorTypein interfaceEntityPersister- Specified by:
getDiscriminatorTypein classAbstractEntityPersister
-
getSubclassByDiscriminatorValue
- Specified by:
getSubclassByDiscriminatorValuein classAbstractEntityPersister
-
getMappedTableDetails
Description copied from interface:EntityMappingTypeDetails for the table this entity maps. Generally this is the same asEntityMappingType.getIdentifierTableDetails(), though may be different for subtypes in joined andunion inheritance hierarchies- See Also:
-
getIdentifierTableDetails
Description copied from interface:EntityMappingTypeDetails for the table that defines the identifier column(s) for an entity hierarchy. -
getDiscriminatorValue
Description copied from interface:EntityMappingTypeThe discriminator value which indicates this entity mapping -
getDiscriminatorSQLValue
-
getSubclassClosure
Deprecated, for removal: This API element is subject to removal in a future version.No longer used. -
getPropertySpaces
Description copied from interface:EntityPersisterReturns 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.
-
isDiscriminatorFormula
protected boolean isDiscriminatorFormula()- Overrides:
isDiscriminatorFormulain classAbstractEntityPersister
-
hasDuplicateTables
public boolean hasDuplicateTables() -
getTableName
-
getKeyColumns
-
isTableCascadeDeleteEnabled
public boolean isTableCascadeDeleteEnabled(int j) - Specified by:
isTableCascadeDeleteEnabledin classAbstractEntityPersister
-
isPropertyOfTable
public boolean isPropertyOfTable(int property, int j) - Specified by:
isPropertyOfTablein classAbstractEntityPersister
-
needsDiscriminator
public boolean needsDiscriminator()- Specified by:
needsDiscriminatorin classAbstractEntityPersister
-
getAttributeMutationTableName
Description copied from interface:EntityMutationTargetThe name of the table to use when performing mutations (INSERT,UPDATE,DELETE) for the given attribute -
getTableSpan
public int getTableSpan() -
addDiscriminatorToInsertGroup
- Specified by:
addDiscriminatorToInsertGroupin interfaceEntityMutationTarget- Overrides:
addDiscriminatorToInsertGroupin classAbstractEntityPersister
-
getPropertyTableNumbers
protected int[] getPropertyTableNumbers()- Specified by:
getPropertyTableNumbersin classAbstractEntityPersister
-
getSubclassTableKeyColumns
- Specified by:
getSubclassTableKeyColumnsin classAbstractEntityPersister
-
getSubclassTableName
-
getSubclassTableNames
- Specified by:
getSubclassTableNamesin classAbstractEntityPersister
-
getSubclassTableSpan
public int getSubclassTableSpan() -
isClassOrSuperclassTable
protected boolean isClassOrSuperclassTable(int j) - Specified by:
isClassOrSuperclassTablein classAbstractEntityPersister
-
isClassOrSuperclassJoin
protected boolean isClassOrSuperclassJoin(int j) - Overrides:
isClassOrSuperclassJoinin classAbstractEntityPersister
-
isNullableTable
public boolean isNullableTable(int j) - Specified by:
isNullableTablein interfaceEntityPersister- Overrides:
isNullableTablein classAbstractEntityPersister
-
isIdentifierTable
- Specified by:
isIdentifierTablein classAbstractEntityPersister
-
isNullableSubclassTable
protected boolean isNullableSubclassTable(int j) - Overrides:
isNullableSubclassTablein classAbstractEntityPersister
-
hasMultipleTables
public boolean hasMultipleTables()- Specified by:
hasMultipleTablesin interfaceEntityPersister- Overrides:
hasMultipleTablesin classAbstractEntityPersister
-
getConstraintOrderedTableNameClosure
- Specified by:
getConstraintOrderedTableNameClosurein classAbstractEntityPersister
-
getConstraintOrderedTableKeyColumnClosure
-
getFilterAliasGenerator
-
pruneForSubclasses
Description copied from interface:EntityMappingTypeAdapts 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
treatedEntityNamesonly 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 forentityNameUses- The entity names under which a table group was used.
-
visitConstraintOrderedTables
-
visitMutabilityOrderedTables
protected void visitMutabilityOrderedTables(AbstractEntityPersister.MutabilityOrderedTableConsumer consumer) Description copied from class:AbstractEntityPersisterVisit 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:
visitMutabilityOrderedTablesin classAbstractEntityPersister- See Also:
-
getDiscriminatorAlias
- Overrides:
getDiscriminatorAliasin classAbstractEntityPersister
-