Class InheritancePolicy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.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 java.io.Serializable, java.lang.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:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addChildDescriptor​(ClassDescriptor childDescriptor)
      INTERNAL: Add child descriptor to the parent descriptor.
      void addChildTableJoinExpressionToAllParents​(org.eclipse.persistence.internal.helper.DatabaseTable table, Expression expression)
      INTERNAL: call addChildTableJoinExpression on all parents
      void addClassIndicator​(java.lang.Class childClass, java.lang.Object typeValue)
      PUBLIC: Add a class indicator for the root classes subclass.
      void addClassIndicatorFieldToInsertRow​(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow)
      INTERNAL: Add abstract class indicator information to the database row.
      void addClassIndicatorFieldToRow​(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow)
      INTERNAL: Add abstract class indicator information to the database row.
      void addClassNameIndicator​(java.lang.String childClassName, java.lang.Object typeValue)
      INTERNAL: Add the class name reference by class name, used by the MW.
      void appendWithAllSubclassesExpression​(org.eclipse.persistence.internal.expressions.SQLSelectStatement selectStatement)
      INTERNAL: Append the branch with all subclasses expression to the statement.
      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.
      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.
      java.lang.Class classFromRow​(org.eclipse.persistence.internal.sessions.AbstractRecord rowFromDatabase, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: This method is invoked only for the abstract descriptors.
      java.lang.Class classFromValue​(java.lang.Object classFieldValue, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: This method is used to turn the a raw database field value classFieldValue into a Class object.
      java.lang.Object clone()
      INTERNAL: Clone the policy
      void convertClassNamesToClasses​(java.lang.ClassLoader classLoader)
      INTERNAL: Convert all the class-name-based settings in this InheritancePolicy to actual class-based settings.
      void dontReadSubclassesOnQueries()
      PUBLIC: Set the descriptor to only read instance of itself when queried.
      void dontUseClassNameAsIndicator()
      PUBLIC: Set the descriptor not to use the class' full name as the indicator.
      java.util.List<ClassDescriptor> getAllChildDescriptors()
      INTERNAL: Returns all the child descriptors, even descriptors for subclasses of subclasses.
      java.util.Vector getAllTables()
      INTERNAL: all tables for reference class plus childrenTables
      java.util.List<ClassDescriptor> getChildDescriptors()
      INTERNAL: Return all the immediate child descriptors.
      Expression getChildrenJoinExpression()
      INTERNAL: all expressions from childrenTablesJoinExpressions ANDed together
      java.util.List<org.eclipse.persistence.internal.helper.DatabaseTable> getChildrenTables()
      INTERNAL: if reads subclasses, all tables for all read subclasses (indirect included).
      java.util.Map<org.eclipse.persistence.internal.helper.DatabaseTable,​Expression> getChildrenTablesJoinExpressions()
      INTERNAL: join expression for each child table, keyed by the table
      java.lang.String getClassExtractionMethodName()
      ADVANCED: A class extraction method can be registered with the descriptor to override the default inheritance mechanism.
      ClassExtractor getClassExtractor()
      ADVANCED: A class extractor can be registered with the descriptor to override the default inheritance mechanism.
      java.util.Vector getClassIndicatorAssociations()
      INTERNAL: Return the class indicator associations for XML.
      org.eclipse.persistence.internal.helper.DatabaseField getClassIndicatorField()
      INTERNAL: Returns field that the class type indicator is store when using inheritance.
      java.lang.String getClassIndicatorFieldName()
      PUBLIC: Return the class indicator field name.
      java.util.Map getClassIndicatorMapping()
      INTERNAL: Return the association of indicators and classes using specified ConversionManager
      java.util.Map getClassNameIndicatorMapping()
      INTERNAL: Return the mapping from class name to indicator, used by MW.
      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.
      ClassDescriptor getDescriptor()
      INTERNAL: Returns the descriptor which the policy belongs to.
      ClassDescriptor getDescriptor​(java.lang.Class theClass)
      INTERNAL: Returns descriptor corresponding to the class owning the policy or its subclass - otherwise null.
      Expression getOnlyInstancesExpression()
      ADVANCED: Return the 'only instances expression'.
      java.lang.Class getParentClass()
      PUBLIC: Return the parent class.
      java.lang.String getParentClassName()
      INTERNAL: Return the parent class name.
      ClassDescriptor getParentDescriptor()
      INTERNAL: Return the parent descriptor.
      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.
      java.lang.String getReadAllSubclassesViewName()
      ADVANCED: The view can be used to optimize/customize the query for all subclasses where they have multiple tables.
      ClassDescriptor getRootParentDescriptor()
      INTERNAL: Return the root parent descriptor
      ClassDescriptor getSubclassDescriptor​(java.lang.Class theClass)
      INTERNAL: use aggregate in inheritance
      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.
      Expression getWithAllSubclassesExpression()
      ADVANCED: Return the Expression which gets all subclasses.
      boolean hasChildren()
      INTERNAL: Check if descriptor has children
      boolean hasClassExtractor()
      INTERNAL:
      boolean hasClassIndicator()
      INTERNAL: Checks if the class is involved in inheritance
      boolean hasMultipleTableChild()
      INTERNAL: Return if any children of this descriptor require information from another table not specified at the parent level.
      boolean hasView()
      INTERNAL: Return if a view is used for inheritance reads.
      void initialize​(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Initialize the inheritance properties of the descriptor once the mappings are initialized.
      boolean isChildDescriptor()
      INTERNAL: Check if it is a child descriptor.
      boolean isJoinedStrategy()
      INTERNAL: Indicate whether a single table or joined inheritance strategy is being used.
      boolean isRootParentDescriptor()
      INTERNAL: Return whether or not is root parent descriptor
      void postInitialize​(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Initialized the inheritance properties that cannot be initialized until after the mappings have been.
      void preInitialize​(org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Allow the inheritance properties of the descriptor to be initialized.
      void readSubclassesOnQueries()
      PUBLIC: Set the descriptor to read instance of itself and its subclasses when queried.
      void remoteInitialization​(DistributedSession session)
      INTERNAL: Used to initialize a remote descriptor.
      boolean requiresMultipleTableSubclassRead()
      INTERNAL: Return if this descriptor has children that define additional tables and needs to read them.
      java.util.Vector selectAllRowUsingMultipleTableSubclassRead​(ObjectLevelReadQuery query)
      INTERNAL: Select all rows from a abstract table descriptor.
      org.eclipse.persistence.internal.sessions.AbstractRecord selectOneRowUsingMultipleTableSubclassRead​(ReadObjectQuery query)
      INTERNAL: Select one row of any concrete subclass, This must use two selects, the first retrieves the type field only.
      void setAlwaysUseOuterJoinForClassType​(boolean choice)
      PUBLIC: Sets the inheritance policy to always use an outer join when querying across a relationship of class.
      void setChildDescriptors​(java.util.List<ClassDescriptor> childDescriptors)
      INTERNAL:
      void setClassExtractionMethodName​(java.lang.String staticClassClassExtractionMethod)
      ADVANCED: A class extraction method can be registered with the descriptor to override the default inheritance mechanism.
      void setClassExtractor​(ClassExtractor classExtractor)
      ADVANCED: A class extractor can be registered with the descriptor to override the default inheritance mechanism.
      void setClassExtractorName​(java.lang.String classExtractorName)
      ADVANCED: Set the class extractor class name.
      void setClassIndicatorAssociations​(java.util.Vector classIndicatorAssociations)
      INTERNAL: Set the class indicator associations from reading the deployment XML.
      void setClassIndicatorField​(org.eclipse.persistence.internal.helper.DatabaseField classIndicatorField)
      ADVANCED: To set the class indicator field.
      void setClassIndicatorFieldName​(java.lang.String fieldName)
      PUBLIC: To set the class indicator field name.
      void setClassIndicatorMapping​(java.util.Map classIndicatorMapping)
      PUBLIC: Set the association of indicators and classes.
      void setClassNameIndicatorMapping​(java.util.Map classNameIndicatorMapping)
      INTERNAL: Set the class name indicator mapping, used by the MW.
      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.
      void setDescriptor​(ClassDescriptor descriptor)
      INTERNAL: Set the descriptor.
      void setJoinedStrategy()
      INTERNAL: Used to indicate a JOINED inheritance strategy.
      void setOnlyInstancesExpression​(Expression onlyInstancesExpression)
      ADVANCED: Sets the expression used to select instance of the class only.
      void setParentClass​(java.lang.Class parentClass)
      PUBLIC: Set the parent class.
      void setParentClassName​(java.lang.String parentClassName)
      INTERNAL: Set the parent class name, used by MW to avoid referencing the real class for deployment XML generation.
      void setParentDescriptor​(ClassDescriptor parentDescriptor)
      INTERNAL:
      void setReadAllSubclassesViewName​(java.lang.String readAllSubclassesViewName)
      ADVANCED: The view can be used to optimize/customize the query for all subclasses where they have multiple tables.
      void setShouldOuterJoinSubclasses​(boolean shouldOuterJoinSubclasses)
      PUBLIC: Set if an outer join should be used to read subclasses.
      void setShouldReadSubclasses​(boolean shouldReadSubclasses)
      PUBLIC: Set the descriptor to read instance of itself and its subclasses when queried.
      void setShouldReadSubclasses​(java.lang.Boolean shouldReadSubclasses)
      INTERNAL: Set the descriptor to read instance of itself and its subclasses when queried.
      void setShouldUseClassNameAsIndicator​(boolean shouldUseClassNameAsIndicator)
      PUBLIC: Set if the descriptor uses the classes fully qualified name as the indicator.
      void setSingleTableStrategy()
      INTERNAL: Used to indicate a SINGLE_TABLE inheritance strategy.
      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.
      void setWithAllSubclassesExpression​(Expression withAllSubclassesExpression)
      ADVANCED: Sets the expression to be used for querying for a class and all its subclasses.
      boolean shouldAlwaysUseOuterJoin()
      PUBLIC: returns if the inheritance policy will always use an outerjoin when selecting class type
      boolean shouldOuterJoinSubclasses()
      PUBLIC: Return if an outer join should be used to read subclasses.
      boolean shouldReadSubclasses()
      PUBLIC: Return true if this descriptor should read instances of itself and subclasses on queries.
      java.lang.Boolean shouldReadSubclassesValue()
      INTERNAL: Return true if this descriptor should read instances of itself and subclasses on queries.
      boolean shouldUseClassNameAsIndicator()
      PUBLIC: Return true if the descriptor use the classes full name as the indicator.
      java.lang.String toString()
      INTERNAL:
      void useClassNameAsIndicator()
      PUBLIC: Set the descriptor to use the classes full name as the indicator.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

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

      • addChildDescriptor

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

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

        public void addClassIndicator​(java.lang.Class childClass,
                                      java.lang.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​(java.lang.String childClassName,
                                          java.lang.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>
      • 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 java.lang.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 java.lang.Class classFromValue​(java.lang.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 java.lang.Object clone()
        INTERNAL: Clone the policy
      • convertClassNamesToClasses

        public void convertClassNamesToClasses​(java.lang.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.
      • 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.
      • getAllChildDescriptors

        public java.util.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>
      • getChildrenTables

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

        public java.util.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 java.util.Vector getAllTables()
        INTERNAL: all tables for reference class plus childrenTables
      • getChildDescriptors

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

        public java.lang.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:
        setWithAllSubclassesExpression(Expression), setOnlyInstancesExpression(Expression)
      • 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:
        setWithAllSubclassesExpression(Expression), setOnlyInstancesExpression(Expression)
      • 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:
        setWithAllSubclassesExpression(Expression), setOnlyInstancesExpression(Expression)
      • setClassExtractorName

        public void setClassExtractorName​(java.lang.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:
        setClassExtractor for more information on the ClassExtractor class.
      • getClassIndicatorAssociations

        public java.util.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 java.lang.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 java.util.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 java.util.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>
      • 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 java.lang.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 java.lang.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 java.lang.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​(java.lang.Class theClass)
        INTERNAL: use aggregate in inheritance
      • getDescriptor

        public ClassDescriptor getDescriptor​(java.lang.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.
      • 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.
      • selectAllRowUsingMultipleTableSubclassRead

        public java.util.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.
      • setChildDescriptors

        public void setChildDescriptors​(java.util.List<ClassDescriptor> childDescriptors)
        INTERNAL:
      • setClassExtractionMethodName

        public void setClassExtractionMethodName​(java.lang.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:
        setWithAllSubclassesExpression(Expression), setOnlyInstancesExpression(Expression)
      • setClassIndicatorAssociations

        public void setClassIndicatorAssociations​(java.util.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​(java.lang.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​(java.util.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​(java.util.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​(java.lang.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​(java.lang.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:
      • setReadAllSubclassesViewName

        public void setReadAllSubclassesViewName​(java.lang.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​(java.lang.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 java.lang.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 java.lang.String toString()
        INTERNAL:
        Overrides:
        toString in class java.lang.Object
      • 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.