Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be 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
Line 2: Line 2:
 
[[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.
 
This section describes the various components that you must configure in order to use a relational aggregate object mapping.
 
 
  
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
 
{| class="Note oac_no_warn" width="80%" border="1" frame="hsides" rules="groups" cellpadding="3" frame="hsides" rules="groups"
Line 13: Line 11:
  
 
For information on how to create EclipseLink mappings, see [[Creating%20a%20Mapping%20(ELUG)|Creating 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 16:
  
 
<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 24:
 
|- 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 31:
 
|- 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 38:
 
|- 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 45:
 
|- 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 52:
 
|- 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 59:
 
|- 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 83:
 
}
 
}
 
</pre>
 
</pre>
 +
  
 
For more information, see the following:
 
For more information, see the following:
Line 98: Line 90:
 
* [[Creating%20and%20Configuring%20Mappings%20(ELUG)|Creating and Configuring Mappings]]
 
* [[Creating%20and%20Configuring%20Mappings%20(ELUG)|Creating and Configuring Mappings]]
  
==Configuring Aggregate Fields==
 
  
 +
 +
==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.
 
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.
  
Line 109: Line 102:
  
 
===How to Configure Aggregate Fields Using Workbench===
 
===How to Configure Aggregate Fields Using Workbench===
 
 
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 116:
 
| 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 134: Line 125:
  
 
===How to Configure Aggregate Fields Using Java===
 
===How to Configure Aggregate Fields Using Java===
 
 
Using the <tt>AggregateObjectMapping</tt> method <tt>addFieldNameTranslation</tt> 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
 
Using the <tt>AggregateObjectMapping</tt> method <tt>addFieldNameTranslation</tt> 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
  
Line 142: Line 132:
  
 
==Configuring Allowing Null Values==
 
==Configuring Allowing Null Values==
 
 
If all the fields in the database row for the aggregate object are <tt>null</tt>, then, by default, EclipseLink places <tt>null</tt> in the appropriate source object, as opposed to filling an aggregate object with <tt>null</tt> values.
 
If all the fields in the database row for the aggregate object are <tt>null</tt>, then, by default, EclipseLink places <tt>null</tt> in the appropriate source object, as opposed to filling an aggregate object with <tt>null</tt> values.
  
Line 148: Line 137:
  
 
===How to Configure Allowing Null Values Using Workbench===
 
===How to Configure Allowing Null Values Using Workbench===
 
 
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 158: Line 145:
  
 
===How to Configure Allowing Null Values Using Java===
 
===How to Configure Allowing Null Values Using Java===
 
 
You can configure whether or not to allow null values using the <tt>AggregateObjectMapping</tt> methods <tt>allowNull</tt> and <tt>dontAllowNull</tt>.
 
You can configure whether or not to allow null values using the <tt>AggregateObjectMapping</tt> methods <tt>allowNull</tt> and <tt>dontAllowNull</tt>.
  
Line 172: Line 158:
 
[[Category: Draft]]
 
[[Category: Draft]]
 
[[Category: Task]]
 
[[Category: Task]]
 +
[[Category: ORM]]

Revision as of 08:03, 17 December 2007

This section describes the various components that you must configure in order to use a relational aggregate object 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).

For information on how to configure EclipseLink mappings options common to two or more mapping types, see Configuring a Mapping.

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

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