Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Configuring a Relational Aggregate Object Mapping (ELUG)"

m (Introduction to Relational Aggregate Object Mapping Configuration)
m (How to Configure Allowing Null Values Using Java)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
<div style="float:right;border:1px solid #000000;padding:5px">__TOC__
 
[[Special:Whatlinkshere/Configuring a Relational Aggregate Object Mapping (ELUG)|Related Topics]]</div>
 
[[Special:Whatlinkshere/Configuring a Relational Aggregate Object Mapping (ELUG)|Related Topics]]</div>
This section describes the various components that you must configure in order to use a relational aggregate object mapping.
 
  
 +
For information on how to create EclipseLink mappings, see [[Creating%20a%20Mapping%20(ELUG)|Creating a Mapping]].
  
  
Line 10: Line 10:
 
|}
 
|}
  
For information on how to configure EclipseLink mappings options common to two or more mapping types, see [[Configuring%20a%20Mapping%20(ELUG)|Configuring a Mapping]].
 
 
For information on how to create EclipseLink mappings, see [[Creating%20a%20Mapping%20(ELUG)|Creating a Mapping]].
 
 
[[#Table 42-1|Configurable Options for Relational Aggregate Object Mapping]] lists the configurable options for a relational aggregate object mapping.
 
 
 
 
==Introduction to Relational Aggregate Object Mapping Configuration==
 
  
 
This table lists the configurable options for a relational aggregate object mapping.
 
This table lists the configurable options for a relational aggregate object mapping.
Line 24: Line 15:
  
 
<span id="Table 42-1"></span>
 
<span id="Table 42-1"></span>
''''' Configurable Options for Relational Aggregate Object Mapping'''''
 
  
 
{| class="RuleFormalMax" dir="ltr" title="Configurable Options for Relational Aggregate Object Mapping" summary="This table lists the configurable options for aggregate mappings and categorizes them as Basic and Advanced and indicates if the option can be configured with the EclipseLink Workbench, Java, or both." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
{| class="RuleFormalMax" dir="ltr" title="Configurable Options for Relational Aggregate Object Mapping" summary="This table lists the configurable options for aggregate mappings and categorizes them as Basic and Advanced and indicates if the option can be configured with the EclipseLink Workbench, Java, or both." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
Line 33: Line 23:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r2c1-t3" headers="r1c1-t3" align="left" |
 
| id="r2c1-t3" headers="r1c1-t3" align="left" |
Reference descriptor (see [[Configuring%20a%20Relational%20Mapping%20(ELUG)|Configuring Reference Descriptor]])
+
[[Configuring%20a%20Relational%20Mapping%20(ELUG)#Configuring Reference Descriptor|Reference descriptor]]
 
| headers="r2c1-t3 r1c2-t3" align="left" |
 
| headers="r2c1-t3 r1c2-t3" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 40: Line 30:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r3c1-t3" headers="r1c1-t3" align="left" |
 
| id="r3c1-t3" headers="r1c1-t3" align="left" |
Method or direct field access (see [[Configuring%20a%20Mapping%20(ELUG)|Configuring a Type Conversion Converter]])
+
[[Configuring%20a%20Mapping%20(ELUG)#Configuring Method or Direct Field Accessing at the Mapping Level|Method or direct field access ]]
 
| headers="r3c1-t3 r1c2-t3" align="left" |
 
| headers="r3c1-t3 r1c2-t3" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 47: Line 37:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r4c1-t3" headers="r1c1-t3" align="left" |
 
| id="r4c1-t3" headers="r1c1-t3" align="left" |
Read-only mapping (see [[Configuring%20a%20Mapping%20(ELUG)|Configuring Read-Only Mappings]])
+
[[Configuring%20a%20Mapping%20(ELUG)#Configuring Read-Only Mappings|Read-only mapping ]]
 
| headers="r4c1-t3 r1c2-t3" align="left" |
 
| headers="r4c1-t3 r1c2-t3" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 54: Line 44:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r5c1-t3" headers="r1c1-t3" align="left" |
 
| id="r5c1-t3" headers="r1c1-t3" align="left" |
Allowing null values (see [[#Configuring Allowing Null Values]])
+
[[#Configuring Allowing Null Values|Allowing null values ]]
 
| headers="r5c1-t3 r1c2-t3" align="left" |
 
| headers="r5c1-t3 r1c2-t3" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 61: Line 51:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r6c1-t3" headers="r1c1-t3" align="left" |
 
| id="r6c1-t3" headers="r1c1-t3" align="left" |
Mapping comments (see [[Configuring%20a%20Mapping%20(ELUG)|Configuring Mapping Comments]])
+
[[Configuring%20a%20Mapping%20(ELUG)#Configuring Mapping Comments|Mapping comments ]]
 
| headers="r6c1-t3 r1c2-t3" align="left" |
 
| headers="r6c1-t3 r1c2-t3" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 68: Line 58:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r7c1-t3" headers="r1c1-t3" align="left" |
 
| id="r7c1-t3" headers="r1c1-t3" align="left" |
Aggregate fields (see [[#Configuring Aggregate Fields]])
+
[[#Configuring Aggregate Fields|Aggregate fields ]]
 
| headers="r7c1-t3 r1c2-t3" align="left" |
 
| headers="r7c1-t3 r1c2-t3" align="left" |
 
[[Image:support.gif|Supported]]
 
[[Image:support.gif|Supported]]
Line 92: Line 82:
 
}
 
}
 
</pre>
 
</pre>
 +
  
 
For more information, see the following:
 
For more information, see the following:
 
* [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Object Mapping|Aggregate Object Mapping]]
 
* [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Object Mapping|Aggregate Object Mapping]]
 
* [[Configuring%20a%20Relational%20Mapping%20(ELUG)|Configuring a Relational Mapping]]
 
* [[Configuring%20a%20Relational%20Mapping%20(ELUG)|Configuring a Relational Mapping]]
* [[Creating%20and%20Configuring%20Mappings%20(ELUG)|Creating and Configuring Mappings]]
+
* [[Configuring%20a%20Mapping%20(ELUG)|Configuring a Mapping]].
 +
 
 +
 
 +
 
  
 
==Configuring Aggregate Fields==
 
==Configuring Aggregate Fields==
Line 111: Line 105:
  
 
To specify the mapped fields of an aggregate mapping, use this procedure.
 
To specify the mapped fields of an aggregate mapping, use this procedure.
 
 
# Select the mapped attribute in the '''Navigator'''. Its properties appear in the Editor.
 
# Select the mapped attribute in the '''Navigator'''. Its properties appear in the Editor.
 
# Click the '''Fields''' tab. The Fields tab appears.<br><span id="Figure 42-1"></span>''''' Fields Tab'''''<br>[[Image:agmapfie.gif|Fields Tab]]
 
# Click the '''Fields''' tab. The Fields tab appears.<br><span id="Figure 42-1"></span>''''' Fields Tab'''''<br>[[Image:agmapfie.gif|Fields Tab]]
Line 125: Line 118:
 
| id="r2c1-t4" headers="r1c1-t4" align="left" | '''Field Description'''
 
| id="r2c1-t4" headers="r1c1-t4" align="left" | '''Field Description'''
 
| headers="r2c1-t4 r1c2-t4" align="left" |
 
| headers="r2c1-t4 r1c2-t4" align="left" |
This column shows the name of the fields from the target object, whose descriptor is designated as an aggregate (see [[Configuring%20a%20Relational%20Descriptor%20(ELUG)#onfiguring a Relational Descriptor as a Class or Aggregate Type|Configuring a Relational Descriptor as a Class or Aggregate Type]]). These are for display only and cannot be changed.
+
This column shows the name of the fields from the target object, whose descriptor is designated [[Configuring%20a%20Relational%20Descriptor%20(ELUG)#Configuring a Relational Descriptor as a Class or Aggregate Type|as an aggregate]]. These are for display only and cannot be changed.
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r3c1-t4" headers="r1c1-t4" align="left" | '''Fields'''
 
| id="r3c1-t4" headers="r1c1-t4" align="left" | '''Fields'''
Line 150: Line 143:
  
 
To allow a mapping to contain a null value, use this procedure.
 
To allow a mapping to contain a null value, use this procedure.
 
 
# Select the mapped attribute in the '''Navigator'''. Its properties appear in the Editor.
 
# Select the mapped attribute in the '''Navigator'''. Its properties appear in the Editor.
 
# Click the '''General''' tab. The General tab appears.<br><span id="Figure 42-2"></span>''''' General Tab, Allow Null Option'''''<br>[[Image:agmapnul.gif|General Tab, Allow Null Option]]
 
# Click the '''General''' tab. The General tab appears.<br><span id="Figure 42-2"></span>''''' General Tab, Allow Null Option'''''<br>[[Image:agmapnul.gif|General Tab, Allow Null Option]]
Line 170: Line 162:
  
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
[[Category: Draft]]
+
[[Category: Release 1]]
 
[[Category: Task]]
 
[[Category: Task]]
 +
[[Category: ORM]]

Latest revision as of 07:35, 20 August 2008

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

Back to the top