Class InheritancePolicy

java.lang.Object
org.eclipse.persistence.core.descriptors.CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
org.eclipse.persistence.descriptors.InheritancePolicy
All Implemented Interfaces:
Serializable, Cloneable

public class InheritancePolicy extends CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField> implements Serializable, Cloneable

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.

See Also:
  • Field Details

    • parentClass

      protected Class parentClass
    • parentClassName

      protected String parentClassName
    • parentDescriptor

      protected ClassDescriptor parentDescriptor
    • childDescriptors

      protected List<ClassDescriptor> childDescriptors
    • classIndicatorField

      protected org.eclipse.persistence.internal.helper.DatabaseField classIndicatorField
    • classIndicatorMapping

      protected transient Map classIndicatorMapping
    • classNameIndicatorMapping

      protected Map classNameIndicatorMapping
    • shouldUseClassNameAsIndicator

      protected transient boolean shouldUseClassNameAsIndicator
    • shouldReadSubclasses

      protected transient Boolean shouldReadSubclasses
    • readAllSubclassesView

      protected org.eclipse.persistence.internal.helper.DatabaseTable readAllSubclassesView
    • allChildClassIndicators

      protected transient List<Object> allChildClassIndicators
    • onlyInstancesExpression

      protected transient Expression onlyInstancesExpression
    • withAllSubclassesExpression

      protected transient Expression withAllSubclassesExpression
    • allTables

      protected transient Vector allTables
    • childrenTables

      protected transient List<org.eclipse.persistence.internal.helper.DatabaseTable> childrenTables
    • childrenTablesJoinExpressions

      protected transient Map<org.eclipse.persistence.internal.helper.DatabaseTable,Expression> childrenTablesJoinExpressions
    • childrenJoinExpression

      protected transient Expression childrenJoinExpression
    • classExtractorName

      protected String classExtractorName
      Allow for class extraction method to be specified.
    • classExtractor

      protected transient ClassExtractor classExtractor
    • descriptor

      protected ClassDescriptor descriptor
    • shouldAlwaysUseOuterJoin

      protected boolean shouldAlwaysUseOuterJoin
    • useDescriptorsToValidateInheritedObjects

      protected boolean useDescriptorsToValidateInheritedObjects
    • shouldOuterJoinSubclasses

      protected boolean shouldOuterJoinSubclasses
      Define if an outer join should be used to read subclasses.
    • isJoinedStrategy

      protected boolean isJoinedStrategy
    • rootParentDescriptor

      protected ClassDescriptor rootParentDescriptor
      PERF: Cache root descriptor.
    • describesNonPersistentSubclasses

      protected boolean describesNonPersistentSubclasses
  • Constructor Details

    • InheritancePolicy

      public InheritancePolicy()
      INTERNAL: Create a new policy. Only descriptors involved in inheritance should have a policy.
    • InheritancePolicy

      public InheritancePolicy(ClassDescriptor descriptor)
      INTERNAL: Create a new policy. Only descriptors involved in inheritance should have a policy.
  • Method Details

    • addChildDescriptor

      public void addChildDescriptor(ClassDescriptor childDescriptor)
      INTERNAL: Add child descriptor to the parent descriptor.
    • addChildTableJoinExpression

      protected void addChildTableJoinExpression(org.eclipse.persistence.internal.helper.DatabaseTable table, Expression expression)
      INTERNAL: childrenTablesJoinExpressions, childrenTables, allTables and childrenJoinExpression are created simultaneously and kept in sync.
    • addChildTableJoinExpressionToAllParents

      public void addChildTableJoinExpressionToAllParents(org.eclipse.persistence.internal.helper.DatabaseTable table, Expression expression)
      INTERNAL: call addChildTableJoinExpression on all parents
    • addClassIndicator

      public void addClassIndicator(Class childClass, Object typeValue)
      PUBLIC: Add a class indicator for the root classes subclass. The indicator is used to determine the class to use for a row read from the database, and to query only instances of a class from the database. Every concrete persistent subclass must have a single unique indicator defined for it. If the root class is concrete then it must also define an indicator. Only the root class's descriptor of the entire inheritance hierarchy can define the class indicator mapping.
    • addClassNameIndicator

      public void addClassNameIndicator(String childClassName, Object typeValue)
      INTERNAL: Add the class name reference by class name, used by the MW.
      Specified by:
      addClassNameIndicator in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • addClassIndicatorFieldToInsertRow

      public void addClassIndicatorFieldToInsertRow(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow)
      INTERNAL: Add abstract class indicator information to the database row. This is required when building a row for an insert or an update of a concrete child descriptor. This is only used to build a template row.
    • addClassIndicatorFieldToRow

      public void addClassIndicatorFieldToRow(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow)
      INTERNAL: Add abstract class indicator information to the database row. This is required when building a row for an insert or an update of a concrete child descriptor.
      Specified by:
      addClassIndicatorFieldToRow in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • addClassIndicatorTypeToParent

      protected void addClassIndicatorTypeToParent(Object indicator)
      INTERNAL: Post initialize the child descriptors
    • addFieldsToParent

      protected void addFieldsToParent(Vector fields)
      INTERNAL: Recursively adds fields to all the parents
    • buildClassIndicatorSelectStatement

      public org.eclipse.persistence.internal.expressions.SQLSelectStatement buildClassIndicatorSelectStatement(ObjectLevelReadQuery query)
      INTERNAL: Return a select statement that will be used to query the class indicators required to query. This is used in the abstract-multiple read.
    • appendWithAllSubclassesExpression

      public void appendWithAllSubclassesExpression(org.eclipse.persistence.internal.expressions.SQLSelectStatement selectStatement)
      INTERNAL: Append the branch with all subclasses expression to the statement.
    • buildViewSelectStatement

      public org.eclipse.persistence.internal.expressions.SQLSelectStatement buildViewSelectStatement(ObjectLevelReadQuery query)
      INTERNAL: Build a select statement for all subclasses on the view using the same selection criteria as the query.
    • classFromRow

      public Class classFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord rowFromDatabase, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
      INTERNAL: This method is invoked only for the abstract descriptors.
      Specified by:
      classFromRow in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
      Throws:
      DescriptorException
    • classFromValue

      public Class classFromValue(Object classFieldValue, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
      INTERNAL: This method is used to turn the a raw database field value classFieldValue into a Class object. Used to determine which class objects to build from database results, and for class type expression
      Throws:
      DescriptorException
    • clone

      public Object clone()
      INTERNAL: Clone the policy
      Overrides:
      clone in class Object
    • convertClassNamesToClasses

      public void convertClassNamesToClasses(ClassLoader classLoader)
      INTERNAL: Convert all the class-name-based settings in this InheritancePolicy to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes. It will also convert referenced classes to the versions of the classes from the classLoader.
    • convertClassNameToClass

      protected <T> Class<T> convertClassNameToClass(String className, ClassLoader classLoader)
      INTERNAL: Convert the given className to an actual class.
    • dontReadSubclassesOnQueries

      public void dontReadSubclassesOnQueries()
      PUBLIC: Set the descriptor to only read instance of itself when queried. This is used with inheritance to configure the result of queries. By default this is true for root inheritance descriptors, and false for all others.
    • dontUseClassNameAsIndicator

      public void dontUseClassNameAsIndicator()
      PUBLIC: Set the descriptor not to use the class' full name as the indicator. The class indicator is used with inheritance to determine the class from a row. By default a class indicator mapping is required, this can be set to true if usage of the class name is desired. The field must be of a large enough size to store the fully qualified class name.
    • getAllChildClassIndicators

      protected List<Object> getAllChildClassIndicators()
      INTERNAL: Stores class indicators for all child and children's children. Used for queries on branch classes only.
    • getAllChildDescriptors

      public List<ClassDescriptor> getAllChildDescriptors()
      INTERNAL: Returns all the child descriptors, even descriptors for subclasses of subclasses. Required for bug 3019934.
      Specified by:
      getAllChildDescriptors in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getAllChildDescriptors

      protected List<ClassDescriptor> getAllChildDescriptors(List<ClassDescriptor> allChildDescriptors)
      INTERNAL: Recursive subroutine of getAllChildDescriptors.
    • getChildrenTables

      public List<org.eclipse.persistence.internal.helper.DatabaseTable> getChildrenTables()
      INTERNAL: if reads subclasses, all tables for all read subclasses (indirect included).
    • getChildrenTablesJoinExpressions

      public Map<org.eclipse.persistence.internal.helper.DatabaseTable,Expression> getChildrenTablesJoinExpressions()
      INTERNAL: join expression for each child table, keyed by the table
    • getChildrenJoinExpression

      public Expression getChildrenJoinExpression()
      INTERNAL: all expressions from childrenTablesJoinExpressions ANDed together
    • getAllTables

      public Vector getAllTables()
      INTERNAL: all tables for reference class plus childrenTables
    • getChildDescriptors

      public List<ClassDescriptor> getChildDescriptors()
      INTERNAL: Return all the immediate child descriptors. Only descriptors from direct subclasses are returned.
    • getClassExtractionMethod

      protected Method getClassExtractionMethod()
      INTERNAL: Return all the classExtractionMethod
    • getClassExtractionMethodName

      public String getClassExtractionMethodName()
      ADVANCED: A class extraction method can be registered with the descriptor to override the default inheritance mechanism. This allows for a user defined class indicator in place of providing an explicit class indicator field. The method registered must be a static method on the class which has that descriptor. The method must take a Record as an argument (for example, a DatabaseRecord), and must return the class to use for that record. This method will be used to decide which class to instantiate when reading from the database. It is the application's responsibility to populate any typing information in the database required to determine the class from the record. If this method is used, then the class indicator field and mapping cannot be used, and in addition, the descriptor's withAllSubclasses and onlyInstances expressions must also be setup correctly.
      See Also:
    • getClassExtractor

      public ClassExtractor getClassExtractor()
      ADVANCED: A class extractor can be registered with the descriptor to override the default inheritance mechanism. This allows for a user defined class indicator in place of providing an explicit class indicator field. The instance registered must extend the ClassExtractor class and implement the extractClass(Map) method. The method must take database row (a Record/Map) as an argument and must return the class to use for that row. This method will be used to decide which class to instantiate when reading from the database. It is the application's responsibility to populate any typing information in the database required to determine the class from the row, such as usage of a direct or transformation mapping for the type fields. If this method is used then the class indicator field and mapping cannot be used, and in addition, the descriptor's withAllSubclasses and onlyInstances expressions must also be setup correctly.
      See Also:
    • setClassExtractor

      public void setClassExtractor(ClassExtractor classExtractor)
      ADVANCED: A class extractor can be registered with the descriptor to override the default inheritance mechanism. This allows for a user defined class indicator in place of providing an explicit class indicator field. The instance registered must extend the ClassExtractor class and implement the extractClass(Map) method. The method must take database row (a Record/Map) as an argument and must return the class to use for that row. This method will be used to decide which class to instantiate when reading from the database. It is the application's responsibility to populate any typing information in the database required to determine the class from the row, such as usage of a direct or transformation mapping for the type fields. If this method is used then the class indicator field and mapping cannot be used, and in addition, the descriptor's withAllSubclasses and onlyInstances expressions must also be setup correctly.
      See Also:
    • setClassExtractorName

      public void setClassExtractorName(String classExtractorName)
      ADVANCED: Set the class extractor class name. At descriptor initialize time this class will be converted to a Class and set as the ClassExtractor. This method is called from JPA.
      Specified by:
      setClassExtractorName in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
      See Also:
    • getClassIndicatorAssociations

      public Vector getClassIndicatorAssociations()
      INTERNAL: Return the class indicator associations for XML. List of class-name/value associations.
    • getClassIndicatorField

      public org.eclipse.persistence.internal.helper.DatabaseField getClassIndicatorField()
      INTERNAL: Returns field that the class type indicator is store when using inheritance.
      Specified by:
      getClassIndicatorField in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getClassIndicatorFieldName

      public String getClassIndicatorFieldName()
      PUBLIC: Return the class indicator field name. This is the name of the field in the table that stores what type of object this is.
      Specified by:
      getClassIndicatorFieldName in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getClassIndicatorMapping

      public Map getClassIndicatorMapping()
      INTERNAL: Return the association of indicators and classes using specified ConversionManager
      Specified by:
      getClassIndicatorMapping in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getClassNameIndicatorMapping

      public Map getClassNameIndicatorMapping()
      INTERNAL: Return the mapping from class name to indicator, used by MW.
      Specified by:
      getClassNameIndicatorMapping in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getClassIndicatorValue

      protected Object getClassIndicatorValue()
      INTERNAL: Returns value of the abstract class indicator for the Java class.
    • getClassIndicatorValue

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

      public ClassDescriptor getDescriptor()
      INTERNAL: Returns the descriptor which the policy belongs to.
      Specified by:
      getDescriptor in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getDescribesNonPersistentSubclasses

      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
    • getOnlyInstancesExpression

      public Expression getOnlyInstancesExpression()
      ADVANCED: Return the 'only instances expression'.
    • getParentClass

      public Class getParentClass()
      PUBLIC: Return the parent class.
      Specified by:
      getParentClass in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getParentClassName

      public String getParentClassName()
      INTERNAL: Return the parent class name.
    • getParentDescriptor

      public ClassDescriptor getParentDescriptor()
      INTERNAL: Return the parent descriptor.
      Specified by:
      getParentDescriptor in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • getReadAllSubclassesView

      public org.eclipse.persistence.internal.helper.DatabaseTable getReadAllSubclassesView()
      INTERNAL: The view can be used to optimize/customize the query for all subclasses where they have multiple tables. This view can do the outer join, we require the view because we cannot generate dynamic platform independent SQL for outer joins (i.e. not possible to do so either).
    • getReadAllSubclassesViewName

      public String getReadAllSubclassesViewName()
      ADVANCED: The view can be used to optimize/customize the query for all subclasses where they have multiple tables. This view can use outer joins or unions to combine the results of selecting from all of the subclass tables. If a view is not given then TopLink must make an individual call for each subclass.
    • getRootParentDescriptor

      public ClassDescriptor getRootParentDescriptor()
      INTERNAL: Return the root parent descriptor
    • getSubclassDescriptor

      public ClassDescriptor getSubclassDescriptor(Class theClass)
      INTERNAL: use aggregate in inheritance
    • getDescriptor

      public ClassDescriptor getDescriptor(Class theClass)
      INTERNAL: Returns descriptor corresponding to the class owning the policy or its subclass - otherwise null.
    • getUseDescriptorsToValidateInheritedObjects

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

      public Expression getWithAllSubclassesExpression()
      ADVANCED: Return the Expression which gets all subclasses.
    • hasChildren

      public boolean hasChildren()
      INTERNAL: Check if descriptor has children
    • hasClassExtractor

      public boolean hasClassExtractor()
      INTERNAL:
      Specified by:
      hasClassExtractor in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • hasClassIndicator

      public boolean hasClassIndicator()
      INTERNAL: Checks if the class is involved in inheritance
    • hasMultipleTableChild

      public boolean hasMultipleTableChild()
      INTERNAL: Return if any children of this descriptor require information from another table not specified at the parent level.
    • hasView

      public boolean hasView()
      INTERNAL: Return if a view is used for inheritance reads.
    • initialize

      public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Initialize the inheritance properties of the descriptor once the mappings are initialized. This is done before formal postInitialize during the end of mapping initialize.
    • initializeClassExtractor

      protected void initializeClassExtractor(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
      INTERNAL: Setup the default classExtractionMethod, or if one was specified by the user make sure it is valid.
      Throws:
      DescriptorException
    • initializeOnlyInstancesExpression

      protected void initializeOnlyInstancesExpression() throws DescriptorException
      INTERNAL: Initialize the expression to use to check the specific type field.
      Throws:
      DescriptorException
    • initializeOptimisticLocking

      protected void initializeOptimisticLocking()
      INTERNAL: Potentially override the optimistic locking behavior
    • initializeCacheInvalidationPolicy

      protected void initializeCacheInvalidationPolicy()
      INTERNAL: Potentially override the cache invalidation behavior
    • initializeWithAllSubclassesExpression

      protected void initializeWithAllSubclassesExpression() throws DescriptorException
      INTERNAL: Initialize the expression to use for queries to the class and its subclasses.
      Throws:
      DescriptorException
    • isChildDescriptor

      public boolean isChildDescriptor()
      INTERNAL: Check if it is a child descriptor.
    • isJoinedStrategy

      public boolean isJoinedStrategy()
      INTERNAL: Indicate whether a single table or joined inheritance strategy is being used. Since we currently do not support TABLE_PER_CLASS, indicating either joined/not joined is sufficient.
      Returns:
      isJoinedStrategy value
    • isRootParentDescriptor

      public boolean isRootParentDescriptor()
      INTERNAL: Return whether or not is root parent descriptor
      Specified by:
      isRootParentDescriptor in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • postInitialize

      public void postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Initialized the inheritance properties that cannot be initialized until after the mappings have been.
    • preInitialize

      public void preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
      INTERNAL: Allow the inheritance properties of the descriptor to be initialized. The descriptor's parent must first be initialized.
      Throws:
      DescriptorException
    • readSubclassesOnQueries

      public void readSubclassesOnQueries()
      PUBLIC: Set the descriptor to read instance of itself and its subclasses when queried. This is used with inheritance to configure the result of queries. By default this is true for root inheritance descriptors, and false for all others.
    • remoteInitialization

      public void remoteInitialization(DistributedSession session)
      INTERNAL: Used to initialize a remote descriptor.
    • requiresMultipleTableSubclassRead

      public boolean requiresMultipleTableSubclassRead()
      INTERNAL: Return if this descriptor has children that define additional tables and needs to read them. This case requires a special read, because the query cannot be done through a single SQL call with normal joins.
    • selectAllRowUsingCustomMultipleTableSubclassRead

      protected Vector selectAllRowUsingCustomMultipleTableSubclassRead(ObjectLevelReadQuery query) throws DatabaseException
      INTERNAL: Select all rows from a abstract table descriptor. This is accomplished by selecting for all of the concrete classes and then merging the rows. This does not optimize using type select, as the type information is not known.
      Returns:
      vector containing database rows.
      Throws:
      DatabaseException - - an error has occurred on the database.
    • selectAllRowUsingDefaultMultipleTableSubclassRead

      protected Vector selectAllRowUsingDefaultMultipleTableSubclassRead(ObjectLevelReadQuery query) throws DatabaseException, QueryException
      INTERNAL: Select all rows from a abstract table descriptor. This is accomplished by selecting for all of the concrete classes and then merging the rows.
      Returns:
      vector containing database rows.
      Throws:
      DatabaseException - - an error has occurred on the database.
      QueryException
    • removeChildren

      protected void removeChildren(ClassDescriptor descriptor, Set<Class> classes, Set<Class> subclasses)
      Remove all of the subclasses (and so on) from the set of classes.
    • selectAllRowUsingMultipleTableSubclassRead

      public Vector selectAllRowUsingMultipleTableSubclassRead(ObjectLevelReadQuery query) throws DatabaseException
      INTERNAL: Select all rows from a abstract table descriptor. This is accomplished by selecting for all of the concrete classes and then merging the rows.
      Returns:
      vector containing database rows.
      Throws:
      DatabaseException - - an error has occurred on the database.
    • selectOneRowUsingCustomMultipleTableSubclassRead

      protected org.eclipse.persistence.internal.sessions.AbstractRecord selectOneRowUsingCustomMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException
      INTERNAL: Select one rows from a abstract table descriptor. This is accomplished by selecting for all of the concrete classes until a row is found. This does not optimize using type select, as the type information is not known.
      Throws:
      DatabaseException - - an error has occurred on the database.
    • selectOneRowUsingDefaultMultipleTableSubclassRead

      protected org.eclipse.persistence.internal.sessions.AbstractRecord selectOneRowUsingDefaultMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException
      INTERNAL: Select one row of any concrete subclass, This must use two selects, the first retrieves the type field only.
      Throws:
      DatabaseException
      QueryException
    • selectOneRowUsingMultipleTableSubclassRead

      public org.eclipse.persistence.internal.sessions.AbstractRecord selectOneRowUsingMultipleTableSubclassRead(ReadObjectQuery query) throws DatabaseException, QueryException
      INTERNAL: Select one row of any concrete subclass, This must use two selects, the first retrieves the type field only.
      Throws:
      DatabaseException
      QueryException
    • setAllChildClassIndicators

      protected void setAllChildClassIndicators(Vector allChildClassIndicators)
      INTERNAL:
    • setChildDescriptors

      public void setChildDescriptors(List<ClassDescriptor> childDescriptors)
      INTERNAL:
    • setClassExtractionMethodName

      public void setClassExtractionMethodName(String staticClassClassExtractionMethod)
      ADVANCED: A class extraction method can be registered with the descriptor to override the default inheritance mechanism. This allows for a user defined class indicator in place of providing an explicit class indicator field. The method registered must be a static method on the class which has that descriptor. The method must take Record as an argument (for example, a DatabaseRecord), and must return the class to use for that record. This method will be used to decide which class to instantiate when reading from the database. It is the application's responsibility to populate any typing information in the database required to determine the class from the record. If this method is used then the class indicator field and mapping cannot be used, and in addition, the descriptor's withAllSubclasses and onlyInstances expressions must also be set up correctly.
      See Also:
    • setClassIndicatorAssociations

      public void setClassIndicatorAssociations(Vector classIndicatorAssociations)
      INTERNAL: Set the class indicator associations from reading the deployment XML.
    • setClassIndicatorField

      public void setClassIndicatorField(org.eclipse.persistence.internal.helper.DatabaseField classIndicatorField)
      ADVANCED: To set the class indicator field. This can be used for advanced field types, such as XML nodes, or to set the field type.
      Specified by:
      setClassIndicatorField in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • setClassIndicatorFieldName

      public void setClassIndicatorFieldName(String fieldName)
      PUBLIC: To set the class indicator field name. This is the name of the field in the table that stores what type of object this is.
    • setClassIndicatorMapping

      public void setClassIndicatorMapping(Map classIndicatorMapping)
      PUBLIC: Set the association of indicators and classes. This may be desired to be used by clients in strange inheritance models.
      Specified by:
      setClassIndicatorMapping in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • setClassNameIndicatorMapping

      public void setClassNameIndicatorMapping(Map classNameIndicatorMapping)
      INTERNAL: Set the class name indicator mapping, used by the MW.
    • setDescriptor

      public void setDescriptor(ClassDescriptor descriptor)
      INTERNAL: Set the descriptor.
      Specified by:
      setDescriptor in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • setDescribesNonPersistentSubclasses

      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
      Parameters:
      describesNonPersistentSubclasses -
    • setJoinedStrategy

      public void setJoinedStrategy()
      INTERNAL: Used to indicate a JOINED inheritance strategy.
    • setOnlyInstancesExpression

      public void setOnlyInstancesExpression(Expression onlyInstancesExpression)
      ADVANCED: Sets the expression used to select instance of the class only. Can be used to customize the inheritance class indicator expression.
    • setParentClass

      public void setParentClass(Class parentClass)
      PUBLIC: Set the parent class. A descriptor can inherit from another descriptor through defining it as its parent. The root descriptor must define a class indicator field and mapping. All children must share the same table as their parent but can add additional tables. All children must share the root descriptor primary key.
    • setParentClassName

      public void setParentClassName(String parentClassName)
      INTERNAL: Set the parent class name, used by MW to avoid referencing the real class for deployment XML generation.
      Specified by:
      setParentClassName in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • setParentDescriptor

      public void setParentDescriptor(ClassDescriptor parentDescriptor)
      INTERNAL:
    • setReadAllSubclassesView

      protected void setReadAllSubclassesView(org.eclipse.persistence.internal.helper.DatabaseTable readAllSubclassesView)
      INTERNAL: The view can be used to optimize/customize the query for all subclasses where they have multiple tables. This view can do the outer join, we require the view because we cannot generate dynamic platform independent SQL for outer joins (i.e. not possible to do so either).
    • setReadAllSubclassesViewName

      public void setReadAllSubclassesViewName(String readAllSubclassesViewName)
      ADVANCED: The view can be used to optimize/customize the query for all subclasses where they have multiple tables. This view can use outer joins or unions to combine the results of selecting from all of the subclass tables. If a view is not given then TopLink must make an individual call for each subclass.
    • setShouldReadSubclasses

      public void setShouldReadSubclasses(Boolean shouldReadSubclasses)
      INTERNAL: Set the descriptor to read instance of itself and its subclasses when queried. This is used with inheritance to configure the result of queries. By default this is true for root inheritance descriptors, and false for all others.
      Specified by:
      setShouldReadSubclasses in class CoreInheritancePolicy<org.eclipse.persistence.internal.sessions.AbstractRecord,org.eclipse.persistence.internal.sessions.AbstractSession,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
    • setShouldReadSubclasses

      public void setShouldReadSubclasses(boolean shouldReadSubclasses)
      PUBLIC: Set the descriptor to read instance of itself and its subclasses when queried. This is used with inheritance to configure the result of queries. By default this is true for root inheritance descriptors, and false for all others.
    • setShouldUseClassNameAsIndicator

      public void setShouldUseClassNameAsIndicator(boolean shouldUseClassNameAsIndicator)
      PUBLIC: Set if the descriptor uses the classes fully qualified name as the indicator. The class indicator is used with inheritance to determine the class from a row. By default a class indicator mapping is required, this can be set to true if usage of the class name is desired. The field must be of a large enough size to store the fully qualified class name.
    • setAlwaysUseOuterJoinForClassType

      public void setAlwaysUseOuterJoinForClassType(boolean choice)
      PUBLIC: Sets the inheritance policy to always use an outer join when querying across a relationship of class. used when using getAllowingNull(), or anyOfAllowingNone()
    • setSingleTableStrategy

      public void setSingleTableStrategy()
      INTERNAL: Used to indicate a SINGLE_TABLE inheritance strategy. Since only JOINED and SINGLE_TABLE strategies are supported at this time (no support for TABLE_PER_CLASS) using a !isJoinedStrategy an an indicator for SINGLE_TABLE is sufficient.
    • setUseDescriptorsToValidateInheritedObjects

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

      public void setWithAllSubclassesExpression(Expression withAllSubclassesExpression)
      ADVANCED: Sets the expression to be used for querying for a class and all its subclasses. Can be used to customize the inheritance class indicator expression.
    • shouldReadSubclasses

      public boolean shouldReadSubclasses()
      PUBLIC: Return true if this descriptor should read instances of itself and subclasses on queries.
    • shouldReadSubclassesValue

      public Boolean shouldReadSubclassesValue()
      INTERNAL: Return true if this descriptor should read instances of itself and subclasses on queries.
    • shouldAlwaysUseOuterJoin

      public boolean shouldAlwaysUseOuterJoin()
      PUBLIC: returns if the inheritance policy will always use an outerjoin when selecting class type
    • shouldOuterJoinSubclasses

      public boolean shouldOuterJoinSubclasses()
      PUBLIC: Return if an outer join should be used to read subclasses. By default a separate query is done for each subclass when querying for a root or branch inheritance class that has subclasses that span multiple tables.
    • setShouldOuterJoinSubclasses

      public void setShouldOuterJoinSubclasses(boolean shouldOuterJoinSubclasses)
      PUBLIC: Set if an outer join should be used to read subclasses. By default a separate query is done for each subclass when querying for a root or branch inheritance class that has subclasses that span multiple tables.
    • shouldUseClassNameAsIndicator

      public boolean shouldUseClassNameAsIndicator()
      PUBLIC: Return true if the descriptor use the classes full name as the indicator. The class indicator is used with inheritance to determine the class from a row. By default a class indicator mapping is required, this can be set to true if usage of the class name is desired. The field must be of a large enough size to store the fully qualified class name.
    • toString

      public String toString()
      INTERNAL:
      Overrides:
      toString in class Object
    • updateTables

      protected void updateTables()
      INTERNAL: set the tables on the child descriptor overridden in org.eclipse.persistence.internal.oxm.QNameInheritancePolicy
    • useClassNameAsIndicator

      public void useClassNameAsIndicator()
      PUBLIC: Set the descriptor to use the classes full name as the indicator. The class indicator is used with inheritance to determine the class from a row. By default a class indicator mapping is required, this can be set to true if usage of the class name is desired. The field must be of a large enough size to store the fully qualified class name.