Skip Headers
Oracle® TopLink Developer's Guide
10g (10.1.3.1.0)
B28218-01
  Go To Documentation Library
Library
Go To Product List
Product
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

Configuring Reading Subclasses on Queries

If you are mapping an inheritance hierarchy, by default, queries on root or branch classes return instances of the root class only.

Alternatively, you can configure a root or branch class descriptor to include subclasses when the root or branch class is queried.

You can also specify a database view to optimize the reading of subclasses. The view can be used to optimize queries for root or branch classes that have subclasses spanning multiple tables. The view must apply an outer-join or union all of the subclass tables.

Do not configure this option for leaf classes.

Table 25-20 summarizes which descriptors support inherited attribute mapping configuration.

Table 25-20 Descriptor Support for Inherited Attribute Mapping Configuration

Descriptor Using TopLink Workbench
Using Java

Relational Descriptors

Supported.


Supported.


Object-Relational Descriptors

Unsupported

Supported.


EIS Descriptors

Unsupported
Unsupported

XML Descriptors

Unsupported
Unsupported

For more information, see "Descriptors and Inheritance".

Using TopLink Workbench

To configure reading classes on subqueries, use this procedure:

  1. In the Navigator, select a root or branch descriptor.

    If the Inheritance advanced property is not visible for the descriptor, right-click the descriptor and choose Select Advanced Properties > Inheritance from context menu or from the Selected menu.

  2. Click the Inheritance tab.

    Figure 25-31 Inheritance Tab, Read Subclasses on Query Option

    Description of Figure 25-31 follows
    Description of "Figure 25-31 Inheritance Tab, Read Subclasses on Query Option"

Use the following information to enter data in Read Subclasses on Query and Read Subclasses View fields of the tab:

Field Description
Read Subclasses on Query Select this option to configure the root class descriptor to instantiate a subclass when the root class is queried.
Read Subclasses View Optionally select a database view to use for reading subclasses.

Using Java

Create a descriptor amendment method ("Configuring Amendment Methods") to customize the root or branch class descriptor's InheritancePolicy using InheritancePolicy method dontReadSubclassesOnQueries to configure a root or branch descriptor to not read subclasses. Optionally, you can use InheritancePolicy method setReadAllSubclassesViewName to optimize multiple table inheritance queries.

Example 25-9 shows an amendment method for the Person class. In this example, subclasses are not read on queries.

Example 25-9 Configuring Reading Subclasses on Queries

...
public static void addToPersonDescriptor(Descriptor descriptor) {
    descriptor.getInheritancePolicy().dontReadSubclassesOnQueries();
}
...