Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
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 28-19 summarizes which descriptors support inherited attribute mapping configuration.
Table 28-19 Descriptor Support for Inherited Attribute Mapping Configuration
Descriptor | Using TopLink Workbench
|
Using Java
|
---|---|---|
Relational Descriptors |
|
|
Object-Relational Descriptors |
![]() |
|
EIS Descriptors |
![]() |
![]() |
XML Descriptors |
![]() |
![]() |
For more information, see "Descriptors and Inheritance".
To configure reading classes on subqueries, use this procedure:
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.
Figure 28-31 Read Subclasses on Query Option, Inheritance 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. |
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 28-9 shows an amendment method for the Person
class. In this example, subclasses are not read on queries.