org.hibernate.persister.entity
Class SingleTableEntityPersister

java.lang.Object
  extended byorg.hibernate.persister.entity.AbstractEntityPersister
      extended byorg.hibernate.persister.entity.SingleTableEntityPersister
All Implemented Interfaces:
ClassMetadata, EntityPersister, Joinable, LazyPropertyInitializer, Loadable, 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

Field Summary
 
Fields inherited from class org.hibernate.persister.entity.AbstractEntityPersister
customSQLDelete, customSQLInsert, customSQLUpdate, deleteCallable, ENTITY_CLASS, insertCallable, propertyMapping, rowIdName, updateCallable
 
Fields inherited from interface org.hibernate.persister.entity.Loadable
ROWID_ALIAS
 
Fields inherited from interface org.hibernate.persister.entity.EntityPersister
ENTITY_ID
 
Fields inherited from interface org.hibernate.intercept.LazyPropertyInitializer
UNFETCHED_PROPERTY
 
Constructor Summary
SingleTableEntityPersister(PersistentClass persistentClass, CacheConcurrencyStrategy cache, 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)
          Get the main from table fragment, given a query alias.
 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 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()
          Get the discriminator type
protected  String[] getKeyColumns(int j)
           
 Serializable[] getPropertySpaces()
          Returns an array of objects that identify spaces in which properties of this class are persisted, for instances of this class only.
 String getPropertyTableName(String propertyName)
          Get the table name for the given property path
protected  int[] getPropertyTableNumbers()
           
protected  int[] getPropertyTableNumbersInSelect()
           
protected  String getSequentialSelect(String entityName)
           
 String[] getSubclassClosure()
           
protected  int[] getSubclassColumnTableNumberClosure()
           
 String getSubclassForDiscriminatorValue(Object value)
          Get the concrete subclass corresponding to the given discriminator value
protected  int[] getSubclassFormulaTableNumberClosure()
           
 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  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, once all ClassPersisters have been instantiated.
 
Methods inherited from class org.hibernate.persister.entity.AbstractEntityPersister
afterInitialize, afterReassociate, check, concretePropertySelectFragment, concretePropertySelectFragmentSansLeadingComma, consumesCollectionAlias, consumesEntityAlias, countSubclassProperties, createEntityLoader, createEntityLoader, createFrom, createJoin, createJoin, createProxy, createQueryLoader, createSelect, createUniqueKeyLoaders, createWhereByKey, dehydrate, dehydrate, delete, delete, filterFragment, findDirty, findModified, fromJoinFragment, generateDeleteString, generateFilterConditionAlias, generateInsertGeneratedValuesSelectString, generateInsertString, generateInsertString, generateInsertString, generateLazySelectString, generateLockString, generateSelectVersionString, generateSnapshotSelectString, generateTableAlias, generateUpdateGeneratedValuesSelectString, generateUpdateString, generateUpdateString, getCache, getCacheEntryStructure, getCascadeStyle, getClassMetadata, getConcreteProxyClass, getCurrentVersion, getDatabaseSnapshot, getDiscriminatorAlias, getEntityMetamodel, getEntityName, getEntityType, getFactory, getFetchMode, getIdentifier, getIdentifierAliases, getIdentifierAliases, getIdentifierColumnNames, getIdentifierColumnSpan, getIdentifierGenerator, getIdentifierPropertyName, getIdentifierType, getIdentitySelectString, getKeyColumnNames, getLazyProperties, getMappedClass, getMappedSuperclass, getName, getNaturalIdentifierProperties, getNaturalIdentifierSnapshot, getNonLazyPropertyUpdateability, getPropertiesToInsert, getPropertiesToUpdate, getPropertyAliases, getPropertyCascadeStyles, getPropertyCheckability, getPropertyColumnNames, getPropertyColumnNames, getPropertyColumnSpan, getPropertyIndex, getPropertyInsertability, getPropertyInsertGeneration, getPropertyLaziness, getPropertyNames, getPropertyNullability, getPropertySpan, getPropertySubclassNames, getPropertyType, getPropertyTypes, getPropertyUpdateability, getPropertyUpdateability, getPropertyUpdateGeneration, getPropertyValue, getPropertyValue, getPropertyValues, getPropertyValuesToInsert, getPropertyVersionability, getQuerySpaces, getRootEntityName, getRootTableKeyColumnNames, getSelectByUniqueKeyString, getSQLDeleteStrings, getSQLIdentityInsertString, getSQLInsertStrings, getSQLLazySelectString, getSQLLazyUpdateByRowIdStrings, getSQLLazyUpdateStrings, getSQLSnapshotSelectString, getSQLUpdateByRowIdStrings, getSQLUpdateStrings, getSQLWhereString, getSubclassColumnAliasClosure, getSubclassColumnClosure, getSubclassColumnLazyiness, getSubclassEntityPersister, getSubclassFormulaAliasClosure, getSubclassFormulaClosure, getSubclassFormulaLazyiness, getSubclassFormulaTemplateClosure, getSubclassPropertyColumnAliases, getSubclassPropertyColumnNameClosure, getSubclassPropertyColumnNames, getSubclassPropertyColumnNames, getSubclassPropertyFormulaTemplateClosure, getSubclassPropertyName, getSubclassPropertyNameClosure, getSubclassPropertySubclassNameClosure, getSubclassPropertyTableNumber, getSubclassPropertyType, getSubclassPropertyTypeClosure, getTableUpdateNeeded, getTemporaryIdTableDDL, getTemporaryIdTableName, getTuplizer, getTuplizer, getType, getVersion, getVersionColumnName, getVersionedTableName, getVersionProperty, getVersionSelectString, getVersionType, guessEntityMode, hasCache, hasCascades, hasCollections, hasEmbeddedCompositeIdentifier, hasFormulaProperties, hasIdentifierProperty, hasIdentifierPropertyOrEmbeddedCompositeIdentifier, hasInsertGeneratedProperties, hasLazyProperties, hasMutableProperties, hasNaturalIdentifier, hasProxy, hasRowId, hasSubclasses, hasSubselectLoadableCollections, hasUninitializedLazyProperties, hasUpdateGeneratedProperties, hasWhere, hydrate, identifierSelectFragment, implementsLifecycle, implementsValidatable, initializeLazyProperty, initLockers, initPropertyPaths, initSubclassPropertyAliasesMap, insert, insert, insert, insert, instantiate, isAbstract, isBatchable, isBatchLoadable, isCacheInvalidationRequired, isCollection, isDefinedOnSubclass, isDeleteCallable, isExplicitPolymorphism, isIdentifierAssignedByInsert, isInherited, isInsertCallable, isInstance, isInstrumented, isLazyPropertiesCacheable, isMutable, isPolymorphic, isSelectBeforeUpdateRequired, isSubclassEntityName, isSubclassPropertyNullable, isTransient, isUpdateCallable, isVersioned, isVersionPropertyGenerated, isVersionPropertyInsertable, load, loadByUniqueKey, lock, logStaticSQL, optimisticLockMode, postConstruct, processInsertGeneratedProperties, processUpdateGeneratedProperties, propertySelectFragment, renderSelect, resetIdentifier, selectFragment, selectFragment, setIdentifier, setPropertyValue, setPropertyValue, setPropertyValues, toColumns, toColumns, toColumns, toString, toType, update, update, updateOrInsert, useDynamicInsert, useDynamicUpdate, useGetGeneratedKeys, useInsertSelectIdentity, whereJoinFragment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SingleTableEntityPersister

public SingleTableEntityPersister(PersistentClass persistentClass,
                                  CacheConcurrencyStrategy cache,
                                  SessionFactoryImplementor factory,
                                  Mapping mapping)
                           throws HibernateException
Method Detail

isInverseTable

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

isInverseSubclassTable

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

getDiscriminatorColumnName

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

getDiscriminatorAlias

protected String getDiscriminatorAlias()
Overrides:
getDiscriminatorAlias in class AbstractEntityPersister

getDiscriminatorFormulaTemplate

protected String getDiscriminatorFormulaTemplate()
Overrides:
getDiscriminatorFormulaTemplate in class AbstractEntityPersister

getTableName

public 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


getDiscriminatorSQLValue

public 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 String[] getSubclassClosure()

getSubclassForDiscriminatorValue

public String getSubclassForDiscriminatorValue(Object value)
Description copied from interface: Loadable
Get the concrete subclass corresponding to the given discriminator value


getPropertySpaces

public Serializable[] getPropertySpaces()
Description copied from interface: EntityPersister
Returns an array of objects that identify spaces in which properties of this class are persisted, for instances of this class only.


isDiscriminatorFormula

protected boolean isDiscriminatorFormula()

getDiscriminatorFormula

protected String getDiscriminatorFormula()

getTableName

protected String getTableName(int j)
Specified by:
getTableName in class AbstractEntityPersister

getKeyColumns

protected String[] getKeyColumns(int j)
Specified by:
getKeyColumns in class AbstractEntityPersister

isTableCascadeDeleteEnabled

protected boolean isTableCascadeDeleteEnabled(int j)
Specified by:
isTableCascadeDeleteEnabled in class AbstractEntityPersister

isPropertyOfTable

protected boolean isPropertyOfTable(int property,
                                    int j)
Specified by:
isPropertyOfTable in class AbstractEntityPersister

isSubclassTableSequentialSelect

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

fromTableFragment

public String fromTableFragment(String name)
Description copied from interface: OuterJoinLoadable
Get the main from table fragment, given a query alias.


filterFragment

public String filterFragment(String alias)
                      throws MappingException
Specified by:
filterFragment in class AbstractEntityPersister
Throws:
MappingException

oneToManyFilterFragment

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

getSubclassPropertyTableName

public 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,
                                        String name,
                                        String suffix)
Overrides:
addDiscriminatorToSelect in class AbstractEntityPersister

getPropertyTableNumbersInSelect

protected int[] getPropertyTableNumbersInSelect()
Specified by:
getPropertyTableNumbersInSelect in class AbstractEntityPersister

getSubclassPropertyTableNumber

protected int getSubclassPropertyTableNumber(int i)
Specified by:
getSubclassPropertyTableNumber in class AbstractEntityPersister

getTableSpan

public int getTableSpan()
Specified by:
getTableSpan in class AbstractEntityPersister

addDiscriminatorToInsert

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

getSubclassColumnTableNumberClosure

protected int[] getSubclassColumnTableNumberClosure()
Specified by:
getSubclassColumnTableNumberClosure in class AbstractEntityPersister

getSubclassFormulaTableNumberClosure

protected int[] getSubclassFormulaTableNumberClosure()
Specified by:
getSubclassFormulaTableNumberClosure in class AbstractEntityPersister

getPropertyTableNumbers

protected int[] getPropertyTableNumbers()
Specified by:
getPropertyTableNumbers in class AbstractEntityPersister

isSubclassPropertyDeferred

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

hasSequentialSelect

public boolean hasSequentialSelect()
Overrides:
hasSequentialSelect in class AbstractEntityPersister

getSequentialSelect

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

getSubclassTableKeyColumns

protected String[] getSubclassTableKeyColumns(int j)
Specified by:
getSubclassTableKeyColumns in class AbstractEntityPersister

getSubclassTableName

public 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 interface Queryable
Specified by:
getSubclassTableName in class AbstractEntityPersister

getSubclassTableSpan

public int getSubclassTableSpan()
Specified by:
getSubclassTableSpan in class AbstractEntityPersister

isClassOrSuperclassTable

protected boolean isClassOrSuperclassTable(int j)
Specified by:
isClassOrSuperclassTable in class AbstractEntityPersister

isSubclassTableLazy

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

isNullableTable

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

isNullableSubclassTable

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

getPropertyTableName

public String getPropertyTableName(String propertyName)
Description copied from interface: OuterJoinLoadable
Get the table name for the given property path


postInstantiate

public void postInstantiate()
Description copied from interface: EntityPersister
Finish the initialization of this object, once all ClassPersisters have been instantiated. Called only once, before any other method.

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

isMultiTable

public boolean isMultiTable()
Description copied from interface: Queryable
Is the inheritence hierarchy described by this persister contained across multiple tables?

Specified by:
isMultiTable in interface Queryable
Overrides:
isMultiTable in class AbstractEntityPersister

getConstraintOrderedTableNameClosure

public 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 contraint violations.

Returns:
The ordered array of table names.

getContraintOrderedTableKeyColumnClosure

public String[][] getContraintOrderedTableKeyColumnClosure()
Description copied from interface: Queryable
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 ;)

Returns: