Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring a Relational Descriptor as a Class or Aggregate Type

By default, when you add a Java class to a relational project (see "Configuring Project Classpath"), TopLink Workbench creates a relational class descriptor for it. A class descriptor is applicable to any persistent object except an object that is owned by another in an aggregate relationship. In this case, you must describe the owned object with an aggregate descriptor. Using a class descriptor, you can configure any relational mapping except aggregate collection and aggregate object mappings.

An aggregate object is an object that is strictly dependent on its owning object. Aggregate descriptors do not define a table, primary key, or many of the standard descriptor options as they obtain these from their owning descriptor. If you want to configure an aggregate mapping to associate data members in a target object with fields in a source object's underlying database tables (see "Configuring a Relational Aggregate Collection Mapping" and "Configuring a Relational Aggregate Object Mapping"), you must designate the target object's descriptor as an aggregate.

Alternatively, you can remove the aggregate designation from a relational descriptor and return it to its default type.

You can configure inheritance for a descriptor designated as an aggregate (see "Configuring Inheritance for a Child (Branch or Leaf) Class Descriptor"), however, in this case, all the descriptors in the inheritance tree must be aggregates. Aggregate and class descriptors cannot exist in the same inheritance tree. For more information, see "Aggregate and Composite Descriptors and Inheritance".

If you configure a descriptor as an aggregate, you cannot configure the descriptor with EJB information (see "Configuring a Descriptor With EJB Information").

For more information, see "Descriptors and Aggregation".

Using TopLink Workbench

To configure a relational descriptor as class or aggregate, use this procedure.

  1. In the Navigator, select a relational descriptor.

  2. Click the Class or Aggregate descriptor button on the mapping toolbar.

    You can also select the descriptor and choose Selected > Descriptor Type > Class or Aggregate from the menu or by right-clicking on the descriptor in the Navigator window and selecting Descriptor Type > Class or Aggregate from the context menu.

  3. Direct to Field Mapping button.
    If you select Aggregate, specify each of the aggregate descriptor's attributes as a direct to field mapping. See Chapter 38, "Configuring a Relational Direct-to-Field Mapping" for more information.

Although the attributes of a target class are not mapped directly to a data source until you configure an aggregate object mapping, you must still specify their mapping type in the target class's descriptor. This tells TopLink what type of mapping to use when you do configure the aggregate mapping in the source object's descriptor. For more information, see "Aggregate and Composite Descriptors in Relational Projects".

Using Java

Using Java, to configure a relational descriptor as an aggregate, use ClassDescriptor method descriptorIsAggregate.

To configure a relational descriptor for use in an aggregate collection mapping, use ClassDescriptor method descriptorIsAggregateCollection.

To configure a relational descriptor as a nonaggregate, use ClassDescriptor method descriptorIsNormal.