org.hibernate.persister.entity

Class SingleTableEntityPersister

Implemented Interfaces:
ClassMetadata, EntityPersister, Joinable, LazyPropertyInitializer, Loadable, Lockable, OptimisticCacheSource, OuterJoinLoadable, PostInsertIdentityPersister, PropertyMapping, Queryable, SQLLoadable, UniqueKeyLoadable

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.
Author:
Gavin King

Nested Class Summary

Nested classes/interfaces inherited from class org.hibernate.persister.entity.AbstractEntityPersister

AbstractEntityPersister.InclusionChecker

Field Summary

Fields inherited from class org.hibernate.persister.entity.AbstractEntityPersister

ENTITY_CLASS, customSQLDelete, customSQLInsert, customSQLUpdate, deleteCallable, deleteResultCheckStyles, insertCallable, insertResultCheckStyles, propertyMapping, rowIdName, updateCallable, updateResultCheckStyles

Fields inherited from interface org.hibernate.persister.entity.EntityPersister

ENTITY_ID

Fields inherited from interface org.hibernate.intercept.LazyPropertyInitializer

UNFETCHED_PROPERTY

Fields inherited from interface org.hibernate.persister.entity.Loadable

ROWID_ALIAS

Constructor Summary

SingleTableEntityPersister(PersistentClass persistentClass, EntityRegionAccessStrategy cacheAccessStrategy, SessionFactoryImplementor factory, Mapping mapping)

Method Summary

protected void
addDiscriminatorToInsert(Insert insert)
protected void
addDiscriminatorToSelect(SelectFragment select, String name, String suffix)
String
filterFragment(String alias)
String
fromTableFragment(String name)
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 contraint violations.
String[][]
getContraintOrderedTableKeyColumnClosure()
For each table specified in Queryable.getConstraintOrderedTableNameClosure(), get the columns that define the key between the various hierarchy classes.
protected String
getDiscriminatorAlias()
String
getDiscriminatorColumnName()
protected String
getDiscriminatorFormula()
protected String
getDiscriminatorFormulaTemplate()
String
getDiscriminatorSQLValue()
Get the discriminator value for this particular concrete subclass, as a string that may be embedded in a select statement
Type
getDiscriminatorType()
protected String[]
getKeyColumns(int j)
Serializable[]
getPropertySpaces()
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class only.
String
getPropertyTableName(String propertyName)
protected int[]
getPropertyTableNumbers()
protected int[]
getPropertyTableNumbersInSelect()
protected String
getSequentialSelect(String entityName)
String[]
getSubclassClosure()
protected int[]
getSubclassColumnTableNumberClosure()
String
getSubclassForDiscriminatorValue(Object value)
protected int[]
getSubclassFormulaTableNumberClosure()
String
getSubclassPropertyTableName(int i)
protected int
getSubclassPropertyTableNumber(int i)
protected String[]
getSubclassTableKeyColumns(int j)
String
getSubclassTableName(int j)
Get the name of the table with the given index from the internal array.
int
getSubclassTableSpan()
String
getTableName()
The table to join to.
protected 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 inheritence 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(String propertyName, String entityName)
protected boolean
isSubclassTableLazy(int j)
protected boolean
isSubclassTableSequentialSelect(int j)
protected boolean
isTableCascadeDeleteEnabled(int j)
String
oneToManyFilterFragment(String alias)
void
postInstantiate()
Finish the initialization of this object.

Methods inherited from class org.hibernate.persister.entity.AbstractEntityPersister

addDiscriminatorToInsert, addDiscriminatorToSelect, afterInitialize, afterReassociate, canExtractIdOutOfEntity, check, concretePropertySelectFragment, concretePropertySelectFragment, concretePropertySelectFragment, concretePropertySelectFragmentSansLeadingComma, consumesCollectionAlias, consumesEntityAlias, countSubclassProperties, createEntityLoader, createEntityLoader, createFrom, createJoin, createJoin, createProxy, createQueryLoader, createSelect, createUniqueKeyLoaders, createWhereByKey, dehydrate, dehydrate, delete, delete, filterFragment, filterFragment, findDirty, findModified, forceVersionIncrement, fromJoinFragment, generateDeleteString, generateFilterConditionAlias, generateIdentityInsertString, generateInsertGeneratedValuesSelectString, generateInsertString, generateInsertString, generateInsertString, generateLazySelectString, generateLocker, generateSelectVersionString, generateSnapshotSelectString, generateTableAlias, generateUpdateGeneratedValuesSelectString, generateUpdateString, generateUpdateString, getCacheAccessStrategy, getCacheEntryStructure, getCascadeStyle, getClassMetadata, getConcreteProxyClass, getCurrentVersion, getDatabaseSnapshot, getDiscriminatorAlias, getDiscriminatorAlias, getDiscriminatorColumnName, getDiscriminatorFormulaTemplate, getEntityMetamodel, getEntityName, getEntityType, getFactory, getFetchMode, getIdentifier, getIdentifierAliases, getIdentifierAliases, getIdentifierColumnNames, getIdentifierColumnSpan, getIdentifierGenerator, getIdentifierPropertyName, getIdentifierType, getIdentitySelectString, getKeyColumnNames, getKeyColumns, getLazyProperties, getMappedClass, getMappedSuperclass, getName, getNaturalIdentifierProperties, getNaturalIdentifierSnapshot, getNonLazyPropertyUpdateability, getPropertiesToInsert, getPropertiesToUpdate, getPropertyAliases, getPropertyCascadeStyles, getPropertyCheckability, getPropertyColumnNames, getPropertyColumnNames, getPropertyColumnSpan, getPropertyIndex, getPropertyInsertGenerationInclusions, getPropertyInsertability, getPropertyLaziness, getPropertyNames, getPropertyNullability, getPropertySpan, getPropertySubclassNames, getPropertyTableNumbers, getPropertyTableNumbersInSelect, getPropertyType, getPropertyTypes, getPropertyUpdateGenerationInclusions, getPropertyUpdateability, getPropertyUpdateability, getPropertyValue, getPropertyValue, getPropertyValues, getPropertyValuesToInsert, getPropertyVersionability, getQuerySpaces, getRootEntityName, getRootTableAlias, getRootTableIdentifierColumnNames, getRootTableKeyColumnNames, getRootTableName, getSQLDeleteStrings, getSQLIdentityInsertString, getSQLInsertStrings, getSQLLazySelectString, getSQLLazyUpdateByRowIdStrings, getSQLLazyUpdateStrings, getSQLSnapshotSelectString, getSQLUpdateByRowIdStrings, getSQLUpdateStrings, getSQLWhereString, getSelectByUniqueKeyString, getSequentialSelect, getSubclassColumnAliasClosure, getSubclassColumnClosure, getSubclassColumnLazyiness, getSubclassColumnTableNumberClosure, getSubclassEntityPersister, getSubclassFormulaAliasClosure, getSubclassFormulaClosure, getSubclassFormulaLazyiness, getSubclassFormulaTableNumberClosure, getSubclassFormulaTemplateClosure, getSubclassPropertyColumnAliases, getSubclassPropertyColumnNameClosure, getSubclassPropertyColumnNames, getSubclassPropertyColumnNames, getSubclassPropertyDeclarer, getSubclassPropertyFormulaTemplateClosure, getSubclassPropertyName, getSubclassPropertyNameClosure, getSubclassPropertySubclassNameClosure, getSubclassPropertyTableNumber, getSubclassPropertyTableNumber, getSubclassPropertyType, getSubclassPropertyTypeClosure, getSubclassTableKeyColumns, getSubclassTableName, getSubclassTableSpan, getTableName, getTableSpan, getTableUpdateNeeded, getTemporaryIdTableDDL, getTemporaryIdTableName, getTuplizer, getTuplizer, getType, getVersion, getVersionColumnName, getVersionComparator, getVersionProperty, getVersionSelectString, getVersionType, getVersionedTableName, guessEntityMode, hasCache, hasCascades, hasCollections, hasEmbeddedCompositeIdentifier, hasFormulaProperties, hasIdentifierProperty, hasInsertGeneratedProperties, hasLazyProperties, hasMutableProperties, hasNaturalIdentifier, hasProxy, hasRowId, hasSequentialSelect, hasSubclasses, hasSubselectLoadableCollections, hasUninitializedLazyProperties, hasUpdateGeneratedProperties, hasWhere, hydrate, identifierSelectFragment, implementsLifecycle, implementsValidatable, initLockers, initPropertyPaths, initSubclassPropertyAliasesMap, initializeLazyProperty, insert, insert, insert, insert, instantiate, isAbstract, isBatchLoadable, isBatchable, isCacheInvalidationRequired, isClassOrSuperclassTable, isCollection, isDefinedOnSubclass, isDeleteCallable, isExplicitPolymorphism, isIdentifierAssignedByInsert, isInherited, isInsertCallable, isInstance, isInstrumented, isInverseSubclassTable, isInverseTable, isLazyPropertiesCacheable, isMultiTable, isMutable, isNullableSubclassTable, isNullableTable, isPolymorphic, isPropertyOfTable, isSelectBeforeUpdateRequired, isSubclassEntityName, isSubclassPropertyDeferred, isSubclassPropertyNullable, isSubclassTableLazy, isSubclassTableSequentialSelect, isTableCascadeDeleteEnabled, isTransient, isUpdateCallable, isVersionPropertyGenerated, isVersionPropertyInsertable, isVersioned, load, loadByUniqueKey, lock, logStaticSQL, oneToManyFilterFragment, optimisticLockMode, postConstruct, postInstantiate, processInsertGeneratedProperties, processUpdateGeneratedProperties, propertySelectFragment, renderSelect, resetIdentifier, selectFragment, selectFragment, setIdentifier, setPropertyValue, setPropertyValue, setPropertyValues, toColumns, toColumns, toColumns, toString, toType, update, update, updateOrInsert, useDynamicInsert, useDynamicUpdate, useGetGeneratedKeys, useInsertSelectIdentity, whereJoinFragment

Constructor Details

SingleTableEntityPersister

public SingleTableEntityPersister(PersistentClass persistentClass,
                                  EntityRegionAccessStrategy cacheAccessStrategy,
                                  SessionFactoryImplementor factory,
                                  Mapping mapping)
            throws HibernateException

Method Details

addDiscriminatorToInsert

protected void addDiscriminatorToInsert(Insert insert)
Overrides:
addDiscriminatorToInsert in interface AbstractEntityPersister

addDiscriminatorToSelect

protected void addDiscriminatorToSelect(SelectFragment select,
                                        String name,
                                        String suffix)
Overrides:
addDiscriminatorToSelect in interface AbstractEntityPersister

filterFragment

public String filterFragment(String alias)
            throws MappingException
Overrides:
filterFragment in interface AbstractEntityPersister

fromTableFragment

public String fromTableFragment(String name)
Specified by:
fromTableFragment in interface OuterJoinLoadable

getConstraintOrderedTableNameClosure

public 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 contraint violations.
Specified by:
getConstraintOrderedTableNameClosure in interface Queryable
Returns:
The ordered array of table names.

getContraintOrderedTableKeyColumnClosure

public String[][] getContraintOrderedTableKeyColumnClosure()
For each table specified in Queryable.getConstraintOrderedTableNameClosure(), get the columns that define the key between the various hierarchy classes.

The first dimension here corresponds to the table indexes returned in Queryable.getConstraintOrderedTableNameClosure().

The second dimension should have the same length across all the elements in the first dimension. If not, that'd be a problem ;)

Specified by:
getContraintOrderedTableKeyColumnClosure in interface Queryable
Returns:

getDiscriminatorAlias

protected String getDiscriminatorAlias()
Overrides:
getDiscriminatorAlias in interface AbstractEntityPersister

getDiscriminatorColumnName

public String getDiscriminatorColumnName()
Specified by:
getDiscriminatorColumnName in interface Loadable
Overrides:
getDiscriminatorColumnName in interface AbstractEntityPersister

getDiscriminatorFormula

protected String getDiscriminatorFormula()

getDiscriminatorFormulaTemplate

protected String getDiscriminatorFormulaTemplate()
Overrides:
getDiscriminatorFormulaTemplate in interface AbstractEntityPersister

getDiscriminatorSQLValue

public String getDiscriminatorSQLValue()
Get the discriminator value for this particular concrete subclass, as a string that may be embedded in a select statement
Specified by:
getDiscriminatorSQLValue in interface Queryable

getDiscriminatorType

public Type getDiscriminatorType()
Specified by:
getDiscriminatorType in interface Loadable

getKeyColumns

protected String[] getKeyColumns(int j)
Overrides:
getKeyColumns in interface AbstractEntityPersister

getPropertySpaces

public Serializable[] getPropertySpaces()
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).

Specified by:
getPropertySpaces in interface EntityPersister
Returns:
The property spaces.

getPropertyTableName

public String getPropertyTableName(String propertyName)
Specified by:
getPropertyTableName in interface OuterJoinLoadable

getPropertyTableNumbers

protected int[] getPropertyTableNumbers()
Overrides:
getPropertyTableNumbers in interface AbstractEntityPersister

getPropertyTableNumbersInSelect

protected int[] getPropertyTableNumbersInSelect()
Overrides:
getPropertyTableNumbersInSelect in interface AbstractEntityPersister

getSequentialSelect

protected String getSequentialSelect(String entityName)
Overrides:
getSequentialSelect in interface AbstractEntityPersister

getSubclassClosure

public String[] getSubclassClosure()

getSubclassColumnTableNumberClosure

protected int[] getSubclassColumnTableNumberClosure()
Overrides:
getSubclassColumnTableNumberClosure in interface AbstractEntityPersister

getSubclassForDiscriminatorValue

public String getSubclassForDiscriminatorValue(Object value)
Specified by:
getSubclassForDiscriminatorValue in interface Loadable

getSubclassFormulaTableNumberClosure

protected int[] getSubclassFormulaTableNumberClosure()
Overrides:
getSubclassFormulaTableNumberClosure in interface AbstractEntityPersister

getSubclassPropertyTableName

public String getSubclassPropertyTableName(int i)
Specified by:
getSubclassPropertyTableName in interface OuterJoinLoadable

getSubclassPropertyTableNumber

protected int getSubclassPropertyTableNumber(int i)
Overrides:
getSubclassPropertyTableNumber in interface AbstractEntityPersister

getSubclassTableKeyColumns

protected String[] getSubclassTableKeyColumns(int j)
Overrides:
getSubclassTableKeyColumns in interface AbstractEntityPersister

getSubclassTableName

public String getSubclassTableName(int j)
Get the name of the table with the given index from the internal array.
Specified by:
getSubclassTableName in interface Queryable
Overrides:
getSubclassTableName in interface AbstractEntityPersister
Parameters:
Returns:

getSubclassTableSpan

public int getSubclassTableSpan()
Overrides:
getSubclassTableSpan in interface AbstractEntityPersister

getTableName

public String getTableName()
The table to join to.
Specified by:
getTableName in interface Joinable

getTableName

protected String getTableName(int j)
Overrides:
getTableName in interface AbstractEntityPersister

getTableSpan

public int getTableSpan()
Overrides:
getTableSpan in interface AbstractEntityPersister

hasSequentialSelect

public boolean hasSequentialSelect()
Overrides:
hasSequentialSelect in interface AbstractEntityPersister

isClassOrSuperclassTable

protected boolean isClassOrSuperclassTable(int j)
Overrides:
isClassOrSuperclassTable in interface AbstractEntityPersister

isDiscriminatorFormula

protected boolean isDiscriminatorFormula()

isInverseSubclassTable

protected boolean isInverseSubclassTable(int j)
Overrides:
isInverseSubclassTable in interface AbstractEntityPersister

isInverseTable

protected boolean isInverseTable(int j)
Overrides:
isInverseTable in interface AbstractEntityPersister

isMultiTable

public boolean isMultiTable()
Is the inheritence hierarchy described by this persister contained across multiple tables?
Specified by:
isMultiTable in interface Queryable
Overrides:
isMultiTable in interface AbstractEntityPersister
Returns:
True if the inheritence hierarchy is spread across multiple tables; false otherwise.

isNullableSubclassTable

protected boolean isNullableSubclassTable(int j)
Overrides:
isNullableSubclassTable in interface AbstractEntityPersister

isNullableTable

protected boolean isNullableTable(int j)
Overrides:
isNullableTable in interface AbstractEntityPersister

isPropertyOfTable

protected boolean isPropertyOfTable(int property,
                                    int j)
Overrides:
isPropertyOfTable in interface AbstractEntityPersister

isSubclassPropertyDeferred

protected boolean isSubclassPropertyDeferred(String propertyName,
                                             String entityName)
Overrides:
isSubclassPropertyDeferred in interface AbstractEntityPersister

isSubclassTableLazy

protected boolean isSubclassTableLazy(int j)
Overrides:
isSubclassTableLazy in interface AbstractEntityPersister

isSubclassTableSequentialSelect

protected boolean isSubclassTableSequentialSelect(int j)
Overrides:
isSubclassTableSequentialSelect in interface AbstractEntityPersister

isTableCascadeDeleteEnabled

protected boolean isTableCascadeDeleteEnabled(int j)
Overrides:
isTableCascadeDeleteEnabled in interface AbstractEntityPersister

oneToManyFilterFragment

public String oneToManyFilterFragment(String alias)
            throws MappingException
Specified by:
oneToManyFilterFragment in interface Joinable
Overrides:
oneToManyFilterFragment in interface AbstractEntityPersister

postInstantiate

public void postInstantiate()
Finish the initialization of this object.

Called only once per SessionFactory lifecycle, after all entity persisters have been instantiated.

Specified by:
postInstantiate in interface EntityPersister
Overrides:
postInstantiate in interface AbstractEntityPersister