Jump to: navigation, search

Configuring a Relational Aggregate Object Mapping (ELUG)

Revision as of 07:35, 20 August 2008 by Rick.sapir.oracle.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

For information on how to create EclipseLink mappings, see Creating a Mapping.


Note: You configure the relational aggregate object mapping in the source object's descriptor. However, before doing so, you must designate the target object's descriptor as an aggregate (see Configuring a Relational Descriptor as a Class or Aggregate Type).


This table lists the configurable options for a relational aggregate object mapping.


Option Workbench Java

Reference descriptor

Supported

Supported

Method or direct field access

Supported

Supported

Read-only mapping

Supported

Supported

Allowing null values

Supported

Supported

Mapping comments

Supported

Unsupported.

Aggregate fields

Supported

Supported


This example shows how to create a aggregate object mapping and add it to a descriptor using Java code.

Aggregate Object Mapping

public void customize(ClassDescriptor descriptor) { 
    AggregateObjectMapping mapping = new AggregateObjectMapping();  

    // configure mapping
    ... 

    // add mapping to descriptor
    descriptor.addMapping(mapping);
}


For more information, see the following:



Configuring Aggregate Fields

When you designate a descriptor as an aggregate, EclipseLink allows you to specify a mapping type for each field in the target class, but defers associating the field with a database table until you configure the aggregate object mapping in the source class descriptor. In other words, the target class descriptor defines how each target class field is mapped but the source class descriptor defines where each target class field is mapped.

This section explains how to configure the source class descriptor to define where each target class field is mapped.

For more information on how to configure the target class descriptor to define how each target class field is mapped, see Configuring a Relational Descriptor as a Class or Aggregate Type.


How to Configure Aggregate Fields Using Workbench

To specify the mapped fields of an aggregate mapping, use this procedure.

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.
  2. Click the Fields tab. The Fields tab appears.
    Fields Tab
    Fields Tab
  3. Complete the fields on the Fields tab.

Use the following information to complete each field on the tab:

Field Description
Field Description

This column shows the name of the fields from the target object, whose descriptor is designated as an aggregate. These are for display only and cannot be changed.

Fields Use this column to select the source object database table field that EclipseLink will map to the corresponding target object field.


How to Configure Aggregate Fields Using Java

Using the AggregateObjectMapping method addFieldNameTranslation you can set a field name translation that maps from a field name in the source table to a field name in the aggregate descriptor

For more information about the available methods for AggregateObjectMapping, see the EclipseLink API Reference.


Configuring Allowing Null Values

If all the fields in the database row for the aggregate object are null, then, by default, EclipseLink places null in the appropriate source object, as opposed to filling an aggregate object with null values.


How to Configure Allowing Null Values Using Workbench

To allow a mapping to contain a null value, use this procedure.

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.
  2. Click the General tab. The General tab appears.
    General Tab, Allow Null Option
    General Tab, Allow Null Option
  3. Select the Allows Null option to allow this mapping to contain a null value.


How to Configure Allowing Null Values Using Java

You can configure whether or not to allow null values using the AggregateObjectMapping methods allowNull and dontAllowNull.

For more information about the available methods for AggregateObjectMapping, see the EclipseLink API Reference.



Copyright Statement