org.hibernate.persister.entity
Class JoinedSubclassEntityPersister

java.lang.Object
  extended by org.hibernate.persister.entity.AbstractEntityPersister
      extended by org.hibernate.persister.entity.JoinedSubclassEntityPersister
All Implemented Interfaces:
OptimisticCacheSource, PostInsertIdentityPersister, LazyPropertyInitializer, ClassMetadata, EntityPersister, Joinable, Loadable, Lockable, OuterJoinLoadable, PropertyMapping, Queryable, SQLLoadable, UniqueKeyLoadable

public class JoinedSubclassEntityPersister
extends AbstractEntityPersister

An EntityPersister implementing the normalized "table-per-subclass" mapping strategy

Author:
Gavin King

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hibernate.persister.entity.AbstractEntityPersister
AbstractEntityPersister.InclusionChecker
 
Nested classes/interfaces inherited from interface org.hibernate.persister.entity.Queryable
Queryable.Declarer
 
Field Summary
 
Fields inherited from class org.hibernate.persister.entity.AbstractEntityPersister
customSQLDelete, customSQLInsert, customSQLUpdate, deleteCallable, deleteResultCheckStyles, ENTITY_CLASS, insertCallable, insertResultCheckStyles, propertyMapping, rowIdName, updateCallable, updateResultCheckStyles
 
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
JoinedSubclassEntityPersister(PersistentClass persistentClass, EntityRegionAccessStrategy cacheAccessStrategy, SessionFactoryImplementor factory, Mapping mapping)
           
 
Method Summary
 void addDiscriminatorToSelect(SelectFragment select, String name, String suffix)
           
 String filterFragment(String alias)
           
 String fromTableFragment(String alias)
          Get the main from table fragment, given a query alias.
 String generateFilterConditionAlias(String rootAlias)
          The alias used for any filter conditions (mapped where-fragments or enabled-filters).
 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.
 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
 String[] getIdentifierColumnNames()
          Get the names of columns used to persist the identifier
 String[] getIdentifierColumnReaders()
           
 String[] getIdentifierColumnReaderTemplates()
           
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)
          Get the table name for the given property path
protected  int[] getPropertyTableNumbers()
           
protected  int[] getPropertyTableNumbersInSelect()
           
 String getRootTableAlias(String drivingAlias)
          Get the SQL alias this persister would use for the root table given the passed driving alias.
 String getRootTableName()
          Locks are always applied to the "root table".
protected  int[] getSubclassColumnTableNumberClosure()
           
 String getSubclassForDiscriminatorValue(Object value)
          Get the concrete subclass corresponding to the given discriminator value
protected  int[] getSubclassFormulaTableNumberClosure()
           
 Queryable.Declarer getSubclassPropertyDeclarer(String propertyPath)
          Determine whether the given property is declared by our mapped class, our super class, or one of our subclasses...
 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()
           
protected  boolean isClassOrSuperclassTable(int j)
           
 boolean isMultiTable()
          Is the inheritence hierarchy described by this persister contained across multiple tables?
protected  boolean isNullableTable(int j)
           
protected  boolean isPropertyOfTable(int property, int j)
           
protected  boolean isSubclassTableLazy(int j)
           
protected  boolean isSubclassTableSequentialSelect(int j)
           
protected  boolean isTableCascadeDeleteEnabled(int j)
           
 String[] toColumns(String alias, String propertyName)
          Given a query alias and a property path, return the qualified column name
 
Methods inherited from class org.hibernate.persister.entity.AbstractEntityPersister
addDiscriminatorToInsert, afterInitialize, afterReassociate, canExtractIdOutOfEntity, check, concretePropertySelectFragment, concretePropertySelectFragment, concretePropertySelectFragment, concretePropertySelectFragmentSansLeadingComma, consumesCollectionAlias, consumesEntityAlias, countSubclassProperties, createEntityLoader, createEntityLoader, createEntityLoader, createFrom, createJoin, createJoin, createLoaders, createProxy, createQueryLoader, createSelect, createUniqueKeyLoaders, createWhereByKey, dehydrate, dehydrate, delete, delete, filterFragment, findDirty, findModified, forceVersionIncrement, fromJoinFragment, generateDeleteString, generateIdentityInsertString, generateInsertGeneratedValuesSelectString, generateInsertString, generateInsertString, generateInsertString, generateLazySelectString, generateLocker, generateSelectVersionString, generateSnapshotSelectString, generateTableAlias, generateUpdateGeneratedValuesSelectString, generateUpdateString, generateUpdateString, getCacheAccessStrategy, getCacheEntryStructure, getCascadeStyle, getClassMetadata, getConcreteProxyClass, getCurrentVersion, getDatabaseSnapshot, getDiscriminatorAlias, getDiscriminatorAlias, getDiscriminatorColumnName, getDiscriminatorColumnReaders, getDiscriminatorColumnReaderTemplate, getDiscriminatorFormulaTemplate, getEntityMetamodel, getEntityName, getEntityType, getFactory, getFetchMode, getIdentifier, getIdentifier, getIdentifierAliases, getIdentifierAliases, getIdentifierColumnSpan, getIdentifierGenerator, getIdentifierPropertyName, getIdentifierType, getIdentitySelectString, getKeyColumnNames, getLazyProperties, getLoaders, getMappedClass, getMappedSuperclass, getName, getNaturalIdentifierProperties, getNaturalIdentifierSnapshot, getNonLazyPropertyUpdateability, 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, getRootTableIdentifierColumnNames, getRootTableKeyColumnNames, getSelectByUniqueKeyString, getSequentialSelect, 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, getSubclassPropertyFormulaTemplateClosure, getSubclassPropertyName, getSubclassPropertyNameClosure, getSubclassPropertySubclassNameClosure, getSubclassPropertyTableNumber, getSubclassPropertyType, getSubclassPropertyTypeClosure, getTableUpdateNeeded, getTemporaryIdTableDDL, getTemporaryIdTableName, getTuplizer, getTuplizer, getType, getTypeDiscriminatorMetadata, getVersion, getVersionColumnName, getVersionComparator, getVersionedTableName, getVersionProperty, getVersionSelectString, getVersionType, guessEntityMode, hasCache, hasCascades, hasCollections, hasEmbeddedCompositeIdentifier, hasFormulaProperties, hasIdentifierProperty, hasInsertGeneratedProperties, hasLazyProperties, hasMutableProperties, hasNaturalIdentifier, hasProxy, hasRowId, hasSequentialSelect, hasSubclasses, hasSubselectLoadableCollections, hasUninitializedLazyProperties, hasUpdateGeneratedProperties, hasWhere, hydrate, identifierSelectFragment, implementsLifecycle, implementsValidatable, initializeLazyProperty, initLockers, initPropertyPaths, initSubclassPropertyAliasesMap, insert, insert, insert, insert, instantiate, instantiate, isAbstract, isBatchable, isBatchLoadable, isCacheInvalidationRequired, isCollection, isDefinedOnSubclass, isDeleteCallable, isExplicitPolymorphism, isIdentifierAssignedByInsert, isInherited, isInsertCallable, isInstance, isInstrumented, isInverseSubclassTable, isInverseTable, isLazyPropertiesCacheable, isMutable, isNullableSubclassTable, isPolymorphic, isSelectBeforeUpdateRequired, isSubclassEntityName, isSubclassPropertyDeferred, isSubclassPropertyNullable, isTransient, isUpdateCallable, isVersioned, isVersionPropertyGenerated, isVersionPropertyInsertable, load, load, loadByUniqueKey, lock, lock, logStaticSQL, oneToManyFilterFragment, optimisticLockMode, postConstruct, postInstantiate, processInsertGeneratedProperties, processUpdateGeneratedProperties, propertySelectFragment, propertySelectFragmentFragment, registerAffectingFetchProfile, renderSelect, resetIdentifier, resetIdentifier, selectFragment, selectFragment, setIdentifier, setIdentifier, setPropertyValue, setPropertyValue, setPropertyValues, 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

JoinedSubclassEntityPersister

public JoinedSubclassEntityPersister(PersistentClass persistentClass,
                                     EntityRegionAccessStrategy cacheAccessStrategy,
                                     SessionFactoryImplementor factory,
                                     Mapping mapping)
                              throws HibernateException
Throws:
HibernateException
Method Detail

isNullableTable

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

isSubclassTableSequentialSelect

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

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.


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


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 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.

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

fromTableFragment

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


getTableName

public String getTableName()
Description copied from interface: Joinable
The table to join to.


addDiscriminatorToSelect

public void addDiscriminatorToSelect(SelectFragment select,
                                     String name,
                                     String suffix)
Overrides:
addDiscriminatorToSelect in class AbstractEntityPersister

filterFragment

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

generateFilterConditionAlias

public String generateFilterConditionAlias(String rootAlias)
Description copied from interface: Queryable
The alias used for any filter conditions (mapped where-fragments or enabled-filters).

This may or may not be different from the root alias depending upon the inheritence mapping strategy.

Specified by:
generateFilterConditionAlias in interface Queryable
Overrides:
generateFilterConditionAlias in class AbstractEntityPersister
Parameters:
rootAlias - The root alias
Returns:
The alias used for "filter conditions" within the where clause.

getIdentifierColumnNames

public String[] getIdentifierColumnNames()
Description copied from interface: Loadable
Get the names of columns used to persist the identifier

Specified by:
getIdentifierColumnNames in interface PostInsertIdentityPersister
Specified by:
getIdentifierColumnNames in interface Loadable
Specified by:
getIdentifierColumnNames in interface Queryable
Overrides:
getIdentifierColumnNames in class AbstractEntityPersister

getIdentifierColumnReaderTemplates

public String[] getIdentifierColumnReaderTemplates()
Overrides:
getIdentifierColumnReaderTemplates in class AbstractEntityPersister

getIdentifierColumnReaders

public String[] getIdentifierColumnReaders()
Overrides:
getIdentifierColumnReaders in class AbstractEntityPersister

toColumns

public String[] toColumns(String alias,
                          String propertyName)
                   throws QueryException
Description copied from interface: PropertyMapping
Given a query alias and a property path, return the qualified column name

Specified by:
toColumns in interface PropertyMapping
Overrides:
toColumns in class AbstractEntityPersister
Throws:
QueryException

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

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
Returns:
True if the inheritence hierarchy is spread across multiple tables; false otherwise.

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

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
Parameters:
j - The index into the internal array.
Returns:

getSubclassTableSpan

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

isSubclassTableLazy

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

isClassOrSuperclassTable

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

getPropertyTableName

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


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:

getRootTableName

public String getRootTableName()
Description copied from interface: Lockable
Locks are always applied to the "root table".

Specified by:
getRootTableName in interface Lockable
Overrides:
getRootTableName in class AbstractEntityPersister
Returns:
The root table name

getRootTableAlias

public String getRootTableAlias(String drivingAlias)
Description copied from interface: Lockable
Get the SQL alias this persister would use for the root table given the passed driving alias.

Specified by:
getRootTableAlias in interface Lockable
Overrides:
getRootTableAlias in class AbstractEntityPersister
Parameters:
drivingAlias - The driving alias; or the alias for the table mapped by this persister in the hierarchy.
Returns:
The root table alias.

getSubclassPropertyDeclarer

public Queryable.Declarer getSubclassPropertyDeclarer(String propertyPath)
Description copied from interface: Queryable
Determine whether the given property is declared by our mapped class, our super class, or one of our subclasses...

Note: the method is called 'subclass property...' simply for consistency sake (e.g. Queryable.getSubclassPropertyTableNumber(java.lang.String)

Specified by:
getSubclassPropertyDeclarer in interface Queryable
Overrides:
getSubclassPropertyDeclarer in class AbstractEntityPersister
Parameters:
propertyPath - The property name.
Returns:
The property declarer


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.