Skip Headers

# Understanding Descriptors and Inheritance

Previous

Next

Inheritance describes how a derived class inherits the characteristics of its superclass. You can use descriptors to describe the inheritance relationships between classes in relational, EIS, and XML projects.

Figure: Example Inheritance Hierarchy illustrates the `Vehicle` object model–a typical Java inheritance hierarchy. The root class `Vehicle` contains two branch classes: `FueledVehicle` and `NonFueledVehicle`. Each branch class contains a leaf class: `Car` and `Bicycle`, respectively.

Example Inheritance Hierarchy

Description of "Example Inheritance Hierarchy "

TopLink recognizes the following three types of classes in an inheritance hierarchy:

1. The root class stores information about all instantiable classes in its subclass hierarchy. By default, queries performed on the root class return instances of the root class and its instantiable subclasses. However, the root class can be configured so queries on it return only instances of itself, without instances of its subclasses.

   For example, the `Vehicle` class in Figure: Example Inheritance Hierarchy is a root class.

2. Branch classes have a persistent superclass and also have subclasses. By default, queries performed on the branch class return instances of the branch class and any of its subclasses. However, as with the root class, the branch class can be configured so queries on it return only instances of itself without instances of its subclasses.

   For example, the `FueledVehicle` class in Figure: Example Inheritance Hierarchy is a branch class.

3. Leaf classes have a persistent superclass in the hierarchy but do not have subclasses. Queries performed on the leaf class can only return instances of the leaf class.

   For example, the `Car` class in Figure: Example Inheritance Hierarchy is a leaf class.

In the descriptor for a child class, you can override mappings that have been specified in the descriptor for a parent class, or map attributes that have not been mapped at all in the parent class descriptor.

This section includes information on the following topics:

- Specifying a Class Indicator

- Inheritance and Primary Keys (Relational and EIS Only)

- Single and Multi-Table Inheritance (Relational Only)

- Aggregate and Composite Descriptors and Inheritance

- Inheritance and EJB

For more information about configuring inheritance for a parent (root) class descriptor, see "Configuring Inheritance for a Parent (Root) Descriptor".

For more information about configuring inheritance for a child (branch or leaf) class descriptor, see "Configuring Inheritance for a Child (Branch or Leaf) Class Descriptor".