Top Description Fields Constructors Methods
org.eclipse.persistence.descriptors

public Class InheritancePolicy

extends CoreInheritancePolicy<AbstractRecord, AbstractSession, ClassDescriptor, DatabaseField>
implements Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable
Known Direct Subclasses
org.eclipse.persistence.internal.oxm.QNameInheritancePolicy
Imports
java.io.Serializable, java.lang.reflect.Method, java.util.ArrayList, .HashMap, .HashSet, .IdentityHashMap, .Iterator, .List, .Map, .Set, .Vector, org.eclipse.persistence.core.descriptors.CoreInheritancePolicy, org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy, org.eclipse.persistence.exceptions.DatabaseException, .DescriptorException, .QueryException, .ValidationException, org.eclipse.persistence.expressions.Expression, .ExpressionBuilder, org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy, org.eclipse.persistence.internal.expressions.SQLSelectStatement, org.eclipse.persistence.internal.helper.ClassConstants, .ConversionManager, .DatabaseField, .DatabaseTable, .Helper, org.eclipse.persistence.internal.queries.ExpressionQueryMechanism, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, org.eclipse.persistence.mappings.Association, .TypedAssociation, org.eclipse.persistence.queries.ObjectLevelReadQuery, .ReadAllQuery, .ReadObjectQuery, org.eclipse.persistence.sessions.remote.DistributedSession

Purpose: Allows customization of an object's inheritance. The primary supported inheritance model uses a class type indicator column in the table that stores the object's class type. The class-to-type mapping is specified on this policy. The full class name can also be used for the indicator instead of the mapping.

Each subclass can either share their parents table, or in addition add their own table(s).

For legacy models a customized inheritance class-extractor can be provided. This allows Java code to be used to compute the class type to use for a row. When this customized inheritance model is used an only-instances and with-all-subclasses filter expression may be required for concrete and branch querying.

Field Summary

Modifier and TypeField and Description
protected transient List<Object>
protected transient Vector<DatabaseTable>
protected List<ClassDescriptor>
protected transient Expression
protected transient List<DatabaseTable>
protected transient Map<DatabaseTable, Expression>
protected transient ClassExtractor
protected String
classExtractorName

Allow for class extraction method to be specified.

protected DatabaseField
protected transient Map<K, V>
protected Map<K, V>
protected boolean
protected ClassDescriptor
protected boolean
protected transient Expression
protected Class<?>
protected String
protected ClassDescriptor
protected DatabaseTable
protected ClassDescriptor
rootParentDescriptor

PERF: Cache root descriptor.

protected boolean
protected boolean
shouldOuterJoinSubclasses

Define if an outer join should be used to read subclasses.

protected transient Boolean
protected transient boolean
protected boolean
protected transient Expression

Constructor Summary

AccessConstructor and Description
public
InheritancePolicy()

INTERNAL: Create a new policy.

public
InheritancePolicy(ClassDescriptor descriptor)

INTERNAL: Create a new policy.

Method Summary

Modifier and TypeMethod and Description
public void
addChildDescriptor(ClassDescriptor childDescriptor)

INTERNAL: Add child descriptor to the parent descriptor.

protected void
addChildTableJoinExpression(DatabaseTable table, Expression expression)

INTERNAL: childrenTablesJoinExpressions, childrenTables, allTables and childrenJoinExpression are created simultaneously and kept in sync.

public void
addChildTableJoinExpressionToAllParents(DatabaseTable table, Expression expression)

INTERNAL: call addChildTableJoinExpression on all parents

public void
addClassIndicator(Class<?> childClass, Object typeValue)

PUBLIC: Add a class indicator for the root classes subclass.

public void
addClassIndicatorFieldToInsertRow(AbstractRecord databaseRow)

INTERNAL: Add abstract class indicator information to the database row.

public void
addClassIndicatorFieldToRow(AbstractRecord databaseRow)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.addClassIndicatorFieldToRow.

INTERNAL: Add abstract class indicator information to the database row.
protected void
addClassIndicatorTypeToParent(Object indicator)

INTERNAL: Post initialize the child descriptors

public void
addClassNameIndicator(String childClassName, Object typeValue)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.addClassNameIndicator.

INTERNAL: Add the class name reference by class name, used by the MW.
protected void
addFieldsToParent(Vector<E> fields)

INTERNAL: Recursively adds fields to all the parents

public void
appendWithAllSubclassesExpression(SQLSelectStatement selectStatement)

INTERNAL: Append the branch with all subclasses expression to the statement.

public SQLSelectStatement
buildClassIndicatorSelectStatement(ObjectLevelReadQuery query)

INTERNAL: Return a select statement that will be used to query the class indicators required to query.

public SQLSelectStatement
buildViewSelectStatement(ObjectLevelReadQuery query)

INTERNAL: Build a select statement for all subclasses on the view using the same selection criteria as the query.

public Class<?>
classFromRow(AbstractRecord rowFromDatabase, AbstractSession session)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.classFromRow.

INTERNAL: This method is invoked only for the abstract descriptors.
public Class<?>
classFromValue(Object classFieldValue, AbstractSession session)

INTERNAL: This method is used to turn the a raw database field value classFieldValue into a Class object.

public Object
clone()

Overrides java.lang.Object.clone.

INTERNAL: Clone the policy
public void
convertClassNamesToClasses(ClassLoader classLoader)

INTERNAL: Convert all the class-name-based settings in this InheritancePolicy to actual class-based settings.

protected <T> Class<T>
convertClassNameToClass(String className, ClassLoader classLoader)

INTERNAL: Convert the given className to an actual class.

public void
dontReadSubclassesOnQueries()

PUBLIC: Set the descriptor to only read instance of itself when queried.

public void
dontUseClassNameAsIndicator()

PUBLIC: Set the descriptor not to use the class' full name as the indicator.

protected List<Object>
getAllChildClassIndicators()

INTERNAL: Stores class indicators for all child and children's children.

public List<ClassDescriptor>
getAllChildDescriptors()

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.getAllChildDescriptors.

INTERNAL: Returns all the child descriptors, even descriptors for subclasses of subclasses.
protected List<ClassDescriptor>
getAllChildDescriptors(List<ClassDescriptor> allChildDescriptors)

INTERNAL: Recursive subroutine of getAllChildDescriptors.

public Vector<DatabaseTable>
getAllTables()

INTERNAL: all tables for reference class plus childrenTables

public List<ClassDescriptor>
getChildDescriptors()

INTERNAL: Return all the immediate child descriptors.

public Expression
getChildrenJoinExpression()

INTERNAL: all expressions from childrenTablesJoinExpressions ANDed together

public List<DatabaseTable>
getChildrenTables()

INTERNAL: if reads subclasses, all tables for all read subclasses (indirect included).

public Map<DatabaseTable, Expression>
getChildrenTablesJoinExpressions()

INTERNAL: join expression for each child table, keyed by the table

protected Method
getClassExtractionMethod()

INTERNAL: Return all the classExtractionMethod

public String
getClassExtractionMethodName()

ADVANCED: A class extraction method can be registered with the descriptor to override the default inheritance mechanism.

public ClassExtractor
getClassExtractor()

ADVANCED: A class extractor can be registered with the descriptor to override the default inheritance mechanism.

public Vector<Association>
getClassIndicatorAssociations()

INTERNAL: Return the class indicator associations for XML.

public DatabaseField
getClassIndicatorField()

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.getClassIndicatorField.

INTERNAL: Returns field that the class type indicator is store when using inheritance.
public String
public Map<K, V>
getClassIndicatorMapping()

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.getClassIndicatorMapping.

INTERNAL: Return the association of indicators and classes using specified ConversionManager
protected Object
getClassIndicatorValue()

INTERNAL: Returns value of the abstract class indicator for the Java class.

protected Object
getClassIndicatorValue(Class<?> javaClass)

INTERNAL: Returns the indicator field value for the given class If no abstract indicator mapping is specified, use the class name.

public Map<K, V>
getClassNameIndicatorMapping()

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.getClassNameIndicatorMapping.

INTERNAL: Return the mapping from class name to indicator, used by MW.
public boolean
getDescribesNonPersistentSubclasses()

ADVANCED: Determines whether the descriptors using this inheritance policy should be used as descriptors for subclasses of the classes they describe if those subclasses do not have their own descriptor e.g. If Employee.class has a descriptor and EmployeeSubClass does not have a descriptor, if describesNonPersistenceSubclasses is true Employee's descriptor will be used as the descriptor for Employee

public ClassDescriptor
getDescriptor()

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.getDescriptor.

INTERNAL: Returns the descriptor which the policy belongs to.
public ClassDescriptor
getDescriptor(Class<?> theClass)

INTERNAL: Returns descriptor corresponding to the class owning the policy or its subclass - otherwise null.

public Expression
getOnlyInstancesExpression()

ADVANCED: Return the 'only instances expression'.

public Class<?>
public String
getParentClassName()

INTERNAL: Return the parent class name.

public ClassDescriptor
public DatabaseTable
getReadAllSubclassesView()

INTERNAL: The view can be used to optimize/customize the query for all subclasses where they have multiple tables.

public String
getReadAllSubclassesViewName()

ADVANCED: The view can be used to optimize/customize the query for all subclasses where they have multiple tables.

public ClassDescriptor
getRootParentDescriptor()

INTERNAL: Return the root parent descriptor

public ClassDescriptor
getSubclassDescriptor(Class<?> theClass)

INTERNAL: use aggregate in inheritance

public boolean
getUseDescriptorsToValidateInheritedObjects()

INTERNAL: return if we should use the descriptor inheritance to determine if an object can be returned from the identity map or not.

public Expression
getWithAllSubclassesExpression()

ADVANCED: Return the Expression which gets all subclasses.

public boolean
hasChildren()

INTERNAL: Check if descriptor has children

public boolean
public boolean
hasClassIndicator()

INTERNAL: Checks if the class is involved in inheritance

public boolean
hasMultipleTableChild()

INTERNAL: Return if any children of this descriptor require information from another table not specified at the parent level.

public boolean
hasView()

INTERNAL: Return if a view is used for inheritance reads.

public void
initialize(AbstractSession session)

INTERNAL: Initialize the inheritance properties of the descriptor once the mappings are initialized.

protected void
initializeCacheInvalidationPolicy()

INTERNAL: Potentially override the cache invalidation behavior

protected void
initializeClassExtractor(AbstractSession session)

INTERNAL: Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid.

protected void
initializeOnlyInstancesExpression()

INTERNAL: Initialize the expression to use to check the specific type field.

protected void
initializeOptimisticLocking()

INTERNAL: Potentially override the optimistic locking behavior

protected void
initializeWithAllSubclassesExpression()

INTERNAL: Initialize the expression to use for queries to the class and its subclasses.

public boolean
isChildDescriptor()

INTERNAL: Check if it is a child descriptor.

public boolean

Returns:

isJoinedStrategy value
isJoinedStrategy
()

INTERNAL: Indicate whether a single table or joined inheritance strategy is being used.

public boolean
isRootParentDescriptor()

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.isRootParentDescriptor.

INTERNAL: Return whether or not is root parent descriptor
public void
postInitialize(AbstractSession session)

INTERNAL: Initialized the inheritance properties that cannot be initialized until after the mappings have been.

public void
preInitialize(AbstractSession session)

INTERNAL: Allow the inheritance properties of the descriptor to be initialized.

public void
readSubclassesOnQueries()

PUBLIC: Set the descriptor to read instance of itself and its subclasses when queried.

public void
remoteInitialization(DistributedSession session)

INTERNAL: Used to initialize a remote descriptor.

protected void
removeChildren(ClassDescriptor descriptor, Set<Class<?>> classes, Set<Class<?>> subclasses)

Remove all of the subclasses (and so on) from the set of classes.

public boolean
requiresMultipleTableSubclassRead()

INTERNAL: Return if this descriptor has children that define additional tables and needs to read them.

protected Vector<E>

Returns:

vector containing database rows.
selectAllRowUsingCustomMultipleTableSubclassRead
(ObjectLevelReadQuery query)

INTERNAL: Select all rows from a abstract table descriptor.

protected Vector<E>

Returns:

vector containing database rows.
selectAllRowUsingDefaultMultipleTableSubclassRead
(ObjectLevelReadQuery query)

INTERNAL: Select all rows from a abstract table descriptor.

public Vector<E>

Returns:

vector containing database rows.
selectAllRowUsingMultipleTableSubclassRead
(ObjectLevelReadQuery query)

INTERNAL: Select all rows from a abstract table descriptor.

protected AbstractRecord
selectOneRowUsingCustomMultipleTableSubclassRead(ReadObjectQuery query)

INTERNAL: Select one rows from a abstract table descriptor.

protected AbstractRecord
selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query)

INTERNAL: Select one row of any concrete subclass, This must use two selects, the first retrieves the type field only.

public AbstractRecord
selectOneRowUsingMultipleTableSubclassRead(ReadObjectQuery query)

INTERNAL: Select one row of any concrete subclass, This must use two selects, the first retrieves the type field only.

protected void
setAllChildClassIndicators(Vector<E> allChildClassIndicators)

INTERNAL:

public void
setAlwaysUseOuterJoinForClassType(boolean choice)

PUBLIC: Sets the inheritance policy to always use an outer join when querying across a relationship of class.

public void
setChildDescriptors(List<ClassDescriptor> childDescriptors)

INTERNAL:

public void
setClassExtractionMethodName(String staticClassClassExtractionMethod)

ADVANCED: A class extraction method can be registered with the descriptor to override the default inheritance mechanism.

public void
setClassExtractor(ClassExtractor classExtractor)

ADVANCED: A class extractor can be registered with the descriptor to override the default inheritance mechanism.

public void
setClassExtractorName(String classExtractorName)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.setClassExtractorName.

ADVANCED: Set the class extractor class name.
public void
setClassIndicatorAssociations(Vector<E> classIndicatorAssociations)

INTERNAL: Set the class indicator associations from reading the deployment XML.

public void
setClassIndicatorField(DatabaseField classIndicatorField)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.setClassIndicatorField.

ADVANCED: To set the class indicator field.
public void
setClassIndicatorFieldName(String fieldName)

PUBLIC: To set the class indicator field name.

public void
setClassIndicatorMapping(Map<K, V> classIndicatorMapping)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.setClassIndicatorMapping.

PUBLIC: Set the association of indicators and classes.
public void
setClassNameIndicatorMapping(Map<K, V> classNameIndicatorMapping)

INTERNAL: Set the class name indicator mapping, used by the MW.

public void
setDescribesNonPersistentSubclasses(boolean describesNonPersistentSubclasses)

ADVANCED: Determines whether the descriptors using this inheritance policy should be used as descriptors for subclasses of the classes they describe if those subclasses do not have their own descriptor e.g. If Employee.class has a descriptor and EmployeeSubClass does not have a descriptor, if describesNonPersistenceSubclasses is true Employee's descriptor will be used as the descriptor for Employee

public void
public void
setJoinedStrategy()

INTERNAL: Used to indicate a JOINED inheritance strategy.

public void
setOnlyInstancesExpression(Expression onlyInstancesExpression)

ADVANCED: Sets the expression used to select instance of the class only.

public void
setParentClass(Class<?> parentClass)

PUBLIC: Set the parent class.

public void
setParentClassName(String parentClassName)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.setParentClassName.

INTERNAL: Set the parent class name, used by MW to avoid referencing the real class for deployment XML generation.
public void
setParentDescriptor(ClassDescriptor parentDescriptor)

INTERNAL:

protected void
setReadAllSubclassesView(DatabaseTable readAllSubclassesView)

INTERNAL: The view can be used to optimize/customize the query for all subclasses where they have multiple tables.

public void
setReadAllSubclassesViewName(String readAllSubclassesViewName)

ADVANCED: The view can be used to optimize/customize the query for all subclasses where they have multiple tables.

public void
setShouldOuterJoinSubclasses(boolean shouldOuterJoinSubclasses)

PUBLIC: Set if an outer join should be used to read subclasses.

public void
setShouldReadSubclasses(Boolean shouldReadSubclasses)

Implements abstract org.eclipse.persistence.core.descriptors.CoreInheritancePolicy.setShouldReadSubclasses.

INTERNAL: Set the descriptor to read instance of itself and its subclasses when queried.
public void
setShouldReadSubclasses(boolean shouldReadSubclasses)

PUBLIC: Set the descriptor to read instance of itself and its subclasses when queried.

public void
setShouldUseClassNameAsIndicator(boolean shouldUseClassNameAsIndicator)

PUBLIC: Set if the descriptor uses the classes fully qualified name as the indicator.

public void
setSingleTableStrategy()

INTERNAL: Used to indicate a SINGLE_TABLE inheritance strategy.

public void
setUseDescriptorsToValidateInheritedObjects(boolean useDescriptorsToValidateInheritedObjects)

INTERNAL: Sets if we should use the descriptor inheritance to determine if an object can be returned from the identity map or not.

public void
setWithAllSubclassesExpression(Expression withAllSubclassesExpression)

ADVANCED: Sets the expression to be used for querying for a class and all its subclasses.

public boolean
shouldAlwaysUseOuterJoin()

PUBLIC: returns if the inheritance policy will always use an outerjoin when selecting class type

public boolean
shouldOuterJoinSubclasses()

PUBLIC: Return if an outer join should be used to read subclasses.

public boolean
shouldReadSubclasses()

PUBLIC: Return true if this descriptor should read instances of itself and subclasses on queries.

public Boolean
shouldReadSubclassesValue()

INTERNAL: Return true if this descriptor should read instances of itself and subclasses on queries.

public boolean
shouldUseClassNameAsIndicator()

PUBLIC: Return true if the descriptor use the classes full name as the indicator.

public String
toString()

Overrides java.lang.Object.toString.

INTERNAL:
protected void
updateTables()

INTERNAL: set the tables on the child descriptor overridden in org.eclipse.persistence.internal.oxm.QNameInheritancePolicy

public void
useClassNameAsIndicator()

PUBLIC: Set the descriptor to use the classes full name as the indicator.