Providing a Class Indicator Field

Use a class indicator field in the table of the root class table to indicate which subclass should be instantiated. The indicator field should not have an associated direct mapping unless it is set to read-only.


Note: If the indicator field is part of the primary key, define a write-only transformation mapping for the indicator field. Refer to "Working with Transformation Mappings" for more information.

You can use strings or numbers as values in the class indicator field. The root class descriptor must specify how the value in the class indicator field translates into the class to be instantiated. The following table illustrates the class indicator mapping from the Vehicle class containing four entries.

Table 4-1 Class Indicator Mapping from the Vehicle Class

Key Value
F FueledVehicle
N NonFueledVehicle
C Car
B Bicycle

When working with hierarchies more than two levels deep, the class indicator field and the class indicator mapping can be in only the root class.


Note: All concrete classes in the hierarchy must have a defined indicator value.

Related Topics

About TopLink Descriptors

Working with Descriptors
Working with Inheritance
Working with Descriptor Properties
Working with Advanced Properties

Finding Subclasses
Understanding Root, Branch, and Leaf Classes in an Inheritance Hierarchy
Specifying Primary Keys in an Inheritance Hierarchy
Mapping Inherited Attributes in a Subclass

 

Copyright © 1997, 2004, Oracle. All rights reserved.