Package org.hibernate.persister.entity
Class SingleTableEntityPersister
- java.lang.Object
-
- org.hibernate.persister.entity.AbstractEntityPersister
-
- org.hibernate.persister.entity.SingleTableEntityPersister
-
- All Implemented Interfaces:
LazyPropertyInitializer
,PostInsertIdentityPersister
,ClassMetadata
,EntityPersister
,Joinable
,Loadable
,Lockable
,OuterJoinLoadable
,PropertyMapping
,Queryable
,SQLLoadable
,UniqueKeyLoadable
,AttributeSource
,EntityDefinition
public class SingleTableEntityPersister extends AbstractEntityPersister
The default implementation of the EntityPersister interface. Implements the "table-per-class-hierarchy" or "roll-up" mapping strategy for an entity class and its inheritence hierarchy. This is implemented as a single table holding all classes in the hierarchy with a discrimator column used to determine which concrete class is referenced.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hibernate.persister.entity.AbstractEntityPersister
AbstractEntityPersister.CacheEntryHelper, AbstractEntityPersister.InclusionChecker
-
Nested classes/interfaces inherited from interface org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer
LazyPropertyInitializer.InterceptorImplementor
-
Nested classes/interfaces inherited from interface org.hibernate.persister.entity.Queryable
Queryable.Declarer
-
-
Field Summary
-
Fields inherited from class org.hibernate.persister.entity.AbstractEntityPersister
batchSize, customSQLDelete, customSQLInsert, customSQLUpdate, deleteCallable, deleteResultCheckStyles, ENTITY_CLASS, insertCallable, insertResultCheckStyles, propertyMapping, rowIdName, updateCallable, updateResultCheckStyles, 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
-
Fields inherited from interface org.hibernate.persister.entity.Loadable
ROWID_ALIAS
-
-
Constructor Summary
Constructors Constructor Description SingleTableEntityPersister(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, PersisterCreationContext creationContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDiscriminatorToInsert(Insert insert)
protected void
addDiscriminatorToSelect(SelectFragment select, java.lang.String name, java.lang.String suffix)
protected void
doPostInstantiate()
java.lang.String
filterFragment(java.lang.String alias)
java.lang.String
filterFragment(java.lang.String alias, java.util.Set<java.lang.String> treatAsDeclarations)
java.lang.String
fromTableFragment(java.lang.String name)
Get the main from table fragment, given a query alias.java.lang.String[]
getConstraintOrderedTableNameClosure()
Get the names of all tables used in the hierarchy (up and down) ordered such that deletes in the given order would not cause constraint violations.java.lang.String[][]
getContraintOrderedTableKeyColumnClosure()
For each table specified inQueryable.getConstraintOrderedTableNameClosure()
, get the columns that define the key between the various hierarchy classes.protected java.lang.String
getDiscriminatorAlias()
java.lang.String
getDiscriminatorColumnName()
java.lang.String
getDiscriminatorColumnReaders()
java.lang.String
getDiscriminatorColumnReaderTemplate()
protected java.lang.String
getDiscriminatorFormula()
protected java.lang.String
getDiscriminatorFormulaTemplate()
java.lang.String
getDiscriminatorSQLValue()
Get the discriminator value for this particular concrete subclass, as a string that may be embedded in a select statementType
getDiscriminatorType()
Get the discriminator typejava.lang.Object
getDiscriminatorValue()
Get the discriminator valueorg.hibernate.internal.FilterAliasGenerator
getFilterAliasGenerator(java.lang.String rootAlias)
protected java.lang.String[]
getKeyColumns(int j)
java.io.Serializable[]
getPropertySpaces()
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class only.java.lang.String
getPropertyTableName(java.lang.String propertyName)
Get the table name for the given property pathprotected int[]
getPropertyTableNumbers()
protected int[]
getPropertyTableNumbersInSelect()
protected java.lang.String
getSequentialSelect(java.lang.String entityName)
java.lang.String[]
getSubclassClosure()
protected int[]
getSubclassColumnTableNumberClosure()
java.lang.String
getSubclassForDiscriminatorValue(java.lang.Object value)
Get the concrete subclass corresponding to the given discriminator valueprotected int[]
getSubclassFormulaTableNumberClosure()
java.lang.String
getSubclassPropertyTableName(int i)
Return the table name used to persist the numbered property of the class or a subclass.protected int
getSubclassPropertyTableNumber(int i)
protected java.lang.String[]
getSubclassTableKeyColumns(int j)
java.lang.String
getSubclassTableName(int j)
Get the name of the table with the given index from the internal array.int
getSubclassTableSpan()
java.lang.String
getTableName()
The table to join to.protected java.lang.String
getTableName(int j)
int
getTableSpan()
boolean
hasSequentialSelect()
protected boolean
isClassOrSuperclassTable(int j)
protected boolean
isDiscriminatorFormula()
protected boolean
isInverseSubclassTable(int j)
protected boolean
isInverseTable(int j)
boolean
isMultiTable()
Is the inheritance hierarchy described by this persister contained across multiple tables?protected boolean
isNullableSubclassTable(int j)
protected boolean
isNullableTable(int j)
protected boolean
isPropertyOfTable(int property, int j)
protected boolean
isSubclassPropertyDeferred(java.lang.String propertyName, java.lang.String entityName)
protected boolean
isSubclassTableLazy(int j)
protected boolean
isSubclassTableSequentialSelect(int j)
protected boolean
isTableCascadeDeleteEnabled(int j)
java.lang.String
oneToManyFilterFragment(java.lang.String alias)
java.lang.String
oneToManyFilterFragment(java.lang.String alias, java.util.Set<java.lang.String> treatAsDeclarations)
-
Methods inherited from class org.hibernate.persister.entity.AbstractEntityPersister
afterInitialize, afterReassociate, buildCacheEntry, buildCacheEntryHelper, canExtractIdOutOfEntity, canReadFromCache, canUseReferenceCacheEntries, canWriteToCache, check, checkVersion, concretePropertySelectFragment, concretePropertySelectFragment, concretePropertySelectFragmentSansLeadingComma, consumesCollectionAlias, consumesEntityAlias, countSubclassProperties, createEntityLoader, createEntityLoader, createEntityLoader, createFrom, createJoin, createJoin, createLoaders, createProxy, createQueryLoader, createSelect, createUniqueKeyLoaders, createWhereByKey, dehydrate, dehydrate, delete, delete, determineSubclassTableJoinType, determineTableName, determineTableNumberForColumn, filterFragment, filterFragment, findDirty, findModified, forceVersionIncrement, fromJoinFragment, fromJoinFragment, generateDeleteString, generateEntityDefinition, generateFilterConditionAlias, generateIdByUniqueKeySelectString, generateIdentityInsertString, generateInsertGeneratedValuesSelectString, generateInsertString, generateInsertString, generateInsertString, generateLazySelectStringsByFetchGroup, generateLocker, generateSelectVersionString, generateSnapshotSelectString, generateTableAlias, generateUpdateGeneratedValuesSelectString, generateUpdateString, generateUpdateString, getAppropriateLoader, getAttributes, getBytecodeEnhancementMetadata, getCacheAccessStrategy, getCacheEntryStructure, getCascadeStyle, getClassMetadata, getCollectionKey, getConcreteProxyClass, getCurrentVersion, getDatabaseSnapshot, getDiscriminatorAlias, getEntityEntryFactory, getEntityKeyDefinition, getEntityMetamodel, getEntityMode, getEntityName, getEntityPersister, getEntityTuplizer, getEntityType, getFactory, getFetchMode, getIdByUniqueKey, getIdentifier, getIdentifier, getIdentifierAliases, getIdentifierAliases, getIdentifierColumnNames, getIdentifierColumnReaders, getIdentifierColumnReaderTemplates, getIdentifierColumnSpan, getIdentifierGenerator, getIdentifierPropertyName, getIdentifierType, getIdentitySelectString, getInstrumentationMetadata, getKeyColumnNames, getLoaderByLockMode, getLoaders, getMappedClass, getMappedSuperclass, getName, getNaturalIdCacheAccessStrategy, getNaturalIdentifierProperties, getNaturalIdentifierSnapshot, getNavigableRole, getNonLazyPropertyUpdateability, getPolymorphicJoinColumns, getPropertiesToInsert, getPropertiesToUpdate, getPropertyAliases, getPropertyCascadeStyles, getPropertyCheckability, getPropertyColumnInsertable, getPropertyColumnNames, getPropertyColumnNames, getPropertyColumnSpan, getPropertyColumnUpdateable, getPropertyColumnWriters, getPropertyIndex, getPropertyInsertability, getPropertyInsertGenerationInclusions, getPropertyLaziness, getPropertyNames, getPropertyNullability, getPropertySelectable, getPropertySpan, getPropertySubclassNames, getPropertyType, getPropertyTypes, getPropertyUniqueness, getPropertyUpdateability, getPropertyUpdateability, getPropertyUpdateGenerationInclusions, getPropertyValue, getPropertyValue, getPropertyValues, getPropertyValuesToInsert, getPropertyVersionability, getQuerySpaces, getRootEntityName, getRootTableAlias, getRootTableIdentifierColumnNames, getRootTableKeyColumnNames, getRootTableName, getSelectByUniqueKeyString, getSQLDeleteStrings, getSQLIdentityInsertString, getSQLInsertStrings, getSQLLazySelectString, getSQLLazyUpdateByRowIdStrings, getSQLLazyUpdateStrings, getSQLSnapshotSelectString, getSQLUpdateByRowIdStrings, getSQLUpdateStrings, getSQLWhereString, getSubclassColumnAliasClosure, getSubclassColumnClosure, getSubclassColumnLazyiness, getSubclassColumnReaderTemplateClosure, getSubclassEntityPersister, getSubclassFormulaAliasClosure, getSubclassFormulaClosure, getSubclassFormulaLazyiness, getSubclassFormulaTemplateClosure, getSubclassPropertyColumnAliases, getSubclassPropertyColumnNameClosure, getSubclassPropertyColumnNames, getSubclassPropertyColumnNames, getSubclassPropertyColumnReaderClosure, getSubclassPropertyColumnReaderTemplateClosure, getSubclassPropertyDeclarer, getSubclassPropertyFormulaTemplateClosure, getSubclassPropertyName, getSubclassPropertyNameClosure, getSubclassPropertySubclassNameClosure, getSubclassPropertyTableNumber, getSubclassPropertyType, getSubclassPropertyTypeClosure, getTableAliasForColumn, getTableId, getTableUpdateNeeded, getTemplateFromString, getType, getTypeDiscriminatorMetadata, getVersion, getVersionColumnName, getVersionComparator, getVersionedTableName, getVersionProperty, getVersionSelectString, getVersionType, hasCache, hasCascades, hasCollections, hasEmbeddedCompositeIdentifier, hasFormulaProperties, hasIdentifierProperty, hasInsertGeneratedProperties, hasLazyProperties, hasMutableProperties, hasNaturalIdCache, hasNaturalIdentifier, hasProxy, hasRowId, hasSubclasses, hasSubselectLoadableCollections, hasUninitializedLazyProperties, hasUpdateGeneratedProperties, hasWhere, hydrate, identifierSelectFragment, implementsLifecycle, initializeEnhancedEntityUsedAsProxy, initializeLazyProperty, initLockers, initPropertyPaths, initSubclassPropertyAliasesMap, insert, insert, insert, insert, instantiate, isAbstract, isAllNull, isBatchable, isBatchLoadable, isCacheInvalidationRequired, isCollection, isDefinedOnSubclass, isDeleteCallable, isExplicitPolymorphism, isIdentifierAssignedByInsert, isInherited, isInsertCallable, isInstance, isInstrumented, isLazyPropertiesCacheable, isModifiableEntity, isMutable, isNaturalIdNonNullable, isPolymorphic, isSelectBeforeUpdateRequired, isSubclassEntityName, isSubclassPropertyNullable, isSubclassTableIndicatedByTreatAsDeclarations, isTransient, isUpdateCallable, isVersioned, isVersionPropertyGenerated, isVersionPropertyInsertable, load, load, loadByUniqueKey, loadEntityIdByNaturalId, lock, lock, logStaticSQL, multiLoad, optimisticLockStyle, postConstruct, postInstantiate, processInsertGeneratedProperties, processUpdateGeneratedProperties, propertySelectFragment, propertySelectFragmentFragment, registerAffectingFetchProfile, renderSelect, resetIdentifier, resolveAttributeIndexes, selectFragment, selectFragment, setIdentifier, setPropertyValue, setPropertyValue, setPropertyValues, toColumns, toColumns, toColumns, toString, toType, update, update, updateOrInsert, useDynamicInsert, useDynamicUpdate, useGetGeneratedKeys, useInsertSelectIdentity, whereJoinFragment, whereJoinFragment
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hibernate.metadata.ClassMetadata
getIdentifier, getPropertyValuesToInsert, instantiate, setIdentifier
-
-
-
-
Constructor Detail
-
SingleTableEntityPersister
public SingleTableEntityPersister(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy, NaturalIdDataAccess naturalIdRegionAccessStrategy, PersisterCreationContext creationContext) throws HibernateException
- Throws:
HibernateException
-
-
Method Detail
-
isInverseTable
protected boolean isInverseTable(int j)
- Overrides:
isInverseTable
in classAbstractEntityPersister
-
isInverseSubclassTable
protected boolean isInverseSubclassTable(int j)
- Overrides:
isInverseSubclassTable
in classAbstractEntityPersister
-
getDiscriminatorColumnName
public java.lang.String getDiscriminatorColumnName()
- Specified by:
getDiscriminatorColumnName
in interfaceLoadable
- Overrides:
getDiscriminatorColumnName
in classAbstractEntityPersister
- Returns:
- the column name for the discriminator as specified in the mapping.
-
getDiscriminatorColumnReaders
public java.lang.String getDiscriminatorColumnReaders()
- Overrides:
getDiscriminatorColumnReaders
in classAbstractEntityPersister
-
getDiscriminatorColumnReaderTemplate
public java.lang.String getDiscriminatorColumnReaderTemplate()
- Overrides:
getDiscriminatorColumnReaderTemplate
in classAbstractEntityPersister
-
getDiscriminatorAlias
protected java.lang.String getDiscriminatorAlias()
- Overrides:
getDiscriminatorAlias
in classAbstractEntityPersister
-
getDiscriminatorFormulaTemplate
protected java.lang.String getDiscriminatorFormulaTemplate()
- Overrides:
getDiscriminatorFormulaTemplate
in classAbstractEntityPersister
-
getTableName
public java.lang.String getTableName()
Description copied from interface:Joinable
The table to join to.
-
getDiscriminatorType
public Type getDiscriminatorType()
Description copied from interface:Loadable
Get the discriminator type
-
getDiscriminatorValue
public java.lang.Object getDiscriminatorValue()
Description copied from interface:Loadable
Get the discriminator value
-
getDiscriminatorSQLValue
public java.lang.String getDiscriminatorSQLValue()
Description copied from interface:Queryable
Get the discriminator value for this particular concrete subclass, as a string that may be embedded in a select statement
-
getSubclassClosure
public java.lang.String[] getSubclassClosure()
-
getSubclassForDiscriminatorValue
public java.lang.String getSubclassForDiscriminatorValue(java.lang.Object value)
Description copied from interface:Loadable
Get the concrete subclass corresponding to the given discriminator value
-
getPropertySpaces
public java.io.Serializable[] 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.
-
isDiscriminatorFormula
protected boolean isDiscriminatorFormula()
-
getDiscriminatorFormula
protected java.lang.String getDiscriminatorFormula()
-
getTableName
protected java.lang.String getTableName(int j)
- Specified by:
getTableName
in classAbstractEntityPersister
-
getKeyColumns
protected java.lang.String[] getKeyColumns(int j)
- Specified by:
getKeyColumns
in classAbstractEntityPersister
-
isTableCascadeDeleteEnabled
protected boolean isTableCascadeDeleteEnabled(int j)
- Specified by:
isTableCascadeDeleteEnabled
in classAbstractEntityPersister
-
isPropertyOfTable
protected boolean isPropertyOfTable(int property, int j)
- Specified by:
isPropertyOfTable
in classAbstractEntityPersister
-
isSubclassTableSequentialSelect
protected boolean isSubclassTableSequentialSelect(int j)
- Overrides:
isSubclassTableSequentialSelect
in classAbstractEntityPersister
-
fromTableFragment
public java.lang.String fromTableFragment(java.lang.String name)
Description copied from interface:OuterJoinLoadable
Get the main from table fragment, given a query alias.
-
filterFragment
public java.lang.String filterFragment(java.lang.String alias) throws MappingException
- Specified by:
filterFragment
in classAbstractEntityPersister
- Throws:
MappingException
-
oneToManyFilterFragment
public java.lang.String oneToManyFilterFragment(java.lang.String alias) throws MappingException
- Specified by:
oneToManyFilterFragment
in interfaceJoinable
- Overrides:
oneToManyFilterFragment
in classAbstractEntityPersister
- Throws:
MappingException
-
oneToManyFilterFragment
public java.lang.String oneToManyFilterFragment(java.lang.String alias, java.util.Set<java.lang.String> treatAsDeclarations)
- Specified by:
oneToManyFilterFragment
in interfaceJoinable
- Overrides:
oneToManyFilterFragment
in classAbstractEntityPersister
-
filterFragment
public java.lang.String filterFragment(java.lang.String alias, java.util.Set<java.lang.String> treatAsDeclarations)
- Specified by:
filterFragment
in classAbstractEntityPersister
-
getSubclassPropertyTableName
public java.lang.String getSubclassPropertyTableName(int i)
Description copied from interface:OuterJoinLoadable
Return the table name used to persist the numbered property of the class or a subclass.
-
addDiscriminatorToSelect
protected void addDiscriminatorToSelect(SelectFragment select, java.lang.String name, java.lang.String suffix)
- Overrides:
addDiscriminatorToSelect
in classAbstractEntityPersister
-
getPropertyTableNumbersInSelect
protected int[] getPropertyTableNumbersInSelect()
- Specified by:
getPropertyTableNumbersInSelect
in classAbstractEntityPersister
-
getSubclassPropertyTableNumber
protected int getSubclassPropertyTableNumber(int i)
- Specified by:
getSubclassPropertyTableNumber
in classAbstractEntityPersister
-
getTableSpan
public int getTableSpan()
- Specified by:
getTableSpan
in classAbstractEntityPersister
-
addDiscriminatorToInsert
protected void addDiscriminatorToInsert(Insert insert)
- Overrides:
addDiscriminatorToInsert
in classAbstractEntityPersister
-
getSubclassColumnTableNumberClosure
protected int[] getSubclassColumnTableNumberClosure()
- Specified by:
getSubclassColumnTableNumberClosure
in classAbstractEntityPersister
-
getSubclassFormulaTableNumberClosure
protected int[] getSubclassFormulaTableNumberClosure()
- Specified by:
getSubclassFormulaTableNumberClosure
in classAbstractEntityPersister
-
getPropertyTableNumbers
protected int[] getPropertyTableNumbers()
- Specified by:
getPropertyTableNumbers
in classAbstractEntityPersister
-
isSubclassPropertyDeferred
protected boolean isSubclassPropertyDeferred(java.lang.String propertyName, java.lang.String entityName)
- Overrides:
isSubclassPropertyDeferred
in classAbstractEntityPersister
-
hasSequentialSelect
public boolean hasSequentialSelect()
- Overrides:
hasSequentialSelect
in classAbstractEntityPersister
-
getSequentialSelect
protected java.lang.String getSequentialSelect(java.lang.String entityName)
- Overrides:
getSequentialSelect
in classAbstractEntityPersister
-
getSubclassTableKeyColumns
protected java.lang.String[] getSubclassTableKeyColumns(int j)
- Specified by:
getSubclassTableKeyColumns
in classAbstractEntityPersister
-
getSubclassTableName
public java.lang.String getSubclassTableName(int j)
Description copied from interface:Queryable
Get the name of the table with the given index from the internal array.- Specified by:
getSubclassTableName
in interfaceQueryable
- Specified by:
getSubclassTableName
in classAbstractEntityPersister
- Parameters:
j
- The index into the internal array.
-
getSubclassTableSpan
public int getSubclassTableSpan()
- Specified by:
getSubclassTableSpan
in classAbstractEntityPersister
-
isClassOrSuperclassTable
protected boolean isClassOrSuperclassTable(int j)
- Specified by:
isClassOrSuperclassTable
in classAbstractEntityPersister
-
isSubclassTableLazy
protected boolean isSubclassTableLazy(int j)
- Overrides:
isSubclassTableLazy
in classAbstractEntityPersister
-
isNullableTable
protected boolean isNullableTable(int j)
- Overrides:
isNullableTable
in classAbstractEntityPersister
-
isNullableSubclassTable
protected boolean isNullableSubclassTable(int j)
- Overrides:
isNullableSubclassTable
in classAbstractEntityPersister
-
getPropertyTableName
public java.lang.String getPropertyTableName(java.lang.String propertyName)
Description copied from interface:OuterJoinLoadable
Get the table name for the given property path
-
doPostInstantiate
protected void doPostInstantiate()
- Overrides:
doPostInstantiate
in classAbstractEntityPersister
-
isMultiTable
public boolean isMultiTable()
Description copied from interface:Queryable
Is the inheritance hierarchy described by this persister contained across multiple tables?- Specified by:
isMultiTable
in interfaceQueryable
- Overrides:
isMultiTable
in classAbstractEntityPersister
- Returns:
- True if the inheritance hierarchy is spread across multiple tables; false otherwise.
-
getConstraintOrderedTableNameClosure
public java.lang.String[] getConstraintOrderedTableNameClosure()
Description copied from interface:Queryable
Get the names of all tables used in the hierarchy (up and down) ordered such that deletes in the given order would not cause constraint violations.- Returns:
- The ordered array of table names.
-
getContraintOrderedTableKeyColumnClosure
public java.lang.String[][] getContraintOrderedTableKeyColumnClosure()
Description copied from interface:Queryable
For each table specified inQueryable.getConstraintOrderedTableNameClosure()
, get the columns that define the key between the various hierarchy classes. The first dimension here corresponds to the table indexes returned inQueryable.getConstraintOrderedTableNameClosure()
. The second dimension should have the same length across all the elements in the first dimension. If not, that would be a problem ;)
-
getFilterAliasGenerator
public org.hibernate.internal.FilterAliasGenerator getFilterAliasGenerator(java.lang.String rootAlias)
-
-