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.
Difference between revisions of "Configuring a Relational Mapping (ELUG)"
m (New page: <div style="float:right;border:1px solid #000000;padding:5px">__TOC__ Related Topics</div> This section describes how to...) |
m (227400) |
||
(15 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 Mapping (ELUG)|Related Topics]]</div> | [[Special:Whatlinkshere/Configuring a Relational Mapping (ELUG)|Related Topics]]</div> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
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]]. | ||
− | |||
− | |||
− | |||
− | |||
This table lists the types of relational mappings that you can configure and provides a cross-reference to the type-specific chapter that lists the configurable options supported by that type. | This table lists the types of relational mappings that you can configure and provides a cross-reference to the type-specific chapter that lists the configurable options supported by that type. | ||
Line 17: | Line 7: | ||
<span id="Table 33-1"></span> | <span id="Table 33-1"></span> | ||
− | |||
− | |||
{| class="HRuleFormalMax" dir="ltr" title="Configuring Relational Mappings" summary="This table provides a cross-reference to additional configuration options for each specific relational mapping type." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows" | {| class="HRuleFormalMax" dir="ltr" title="Configuring Relational Mappings" summary="This table provides a cross-reference to additional configuration options for each specific relational mapping type." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows" | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
Line 25: | Line 13: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t2" headers="r1c1-t2" align="left" | | | id="r2c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Direct-to-Field Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct-to-Field Mapping|Direct-to-Field Mapping]] |
| headers="r2c1-t2 r1c2-t2" align="left" | | | headers="r2c1-t2 r1c2-t2" align="left" | | ||
− | [[Configuring | + | [[Configuring a Relational Direct-to-Field Mapping (ELUG)|Configuring a Relational Direct-to-Field Mapping]] |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t2" headers="r1c1-t2" align="left" | | | id="r3c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Transformation Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Transformation Mapping|Transformation Mapping]] |
| headers="r3c1-t2 r1c2-t2" align="left" | | | headers="r3c1-t2 r1c2-t2" align="left" | | ||
[[Configuring%20a%20Relational%20Transformation%20Mapping%20(ELUG)|Configuring a Relational Transformation Mapping]] | [[Configuring%20a%20Relational%20Transformation%20Mapping%20(ELUG)|Configuring a Relational Transformation Mapping]] | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t2" headers="r1c1-t2" align="left" | | | id="r4c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Direct-to-XMLType Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct-to-XMLType Mapping|Direct-to-XMLType Mapping]] |
| headers="r4c1-t2 r1c2-t2" align="left" | | | headers="r4c1-t2 r1c2-t2" align="left" | | ||
− | [[Configuring | + | [[Configuring a Relational Direct-to-XMLType Mapping (ELUG)|Configuring a Relational Direct-to-XMLType Mapping]] |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r5c1-t2" headers="r1c1-t2" align="left" | | | id="r5c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|One-to-One Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-One Mapping|One-to-One Mapping]] |
| headers="r5c1-t2 r1c2-t2" align="left" | | | headers="r5c1-t2 r1c2-t2" align="left" | | ||
− | [[Configuring%20a%20Relational%20One-to-One%20Mapping%20(ELUG)| | + | [[Configuring%20a%20Relational%20One-to-One%20Mapping%20(ELUG)|Configuring a Relational One-to-One Mapping]] |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r6c1-t2" headers="r1c1-t2" align="left" | | | id="r6c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Variable One-to-One Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Variable One-to-One Mapping|Variable One-to-One Mapping]] |
| headers="r6c1-t2 r1c2-t2" align="left" | | | headers="r6c1-t2 r1c2-t2" align="left" | | ||
[[Configuring%20a%20Relational%20Variable%20One-to-One%20Mapping%20(ELUG)|Configuring a Relational Variable One-to-One Mapping]] | [[Configuring%20a%20Relational%20Variable%20One-to-One%20Mapping%20(ELUG)|Configuring a Relational Variable One-to-One Mapping]] | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r7c1-t2" headers="r1c1-t2" align="left" | | | id="r7c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|One-to-Many Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-Many Mapping|One-to-Many Mapping]] |
| headers="r7c1-t2 r1c2-t2" align="left" | | | headers="r7c1-t2 r1c2-t2" align="left" | | ||
− | [[Configuring | + | [[Configuring a Relational One-to-Many Mapping (ELUG)|Configuring a Relational One-to-Many Mapping]] |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r8c1-t2" headers="r1c1-t2" align="left" | | | id="r8c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Many-to-Many Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Many-to-Many Mapping|Many-to-Many Mapping]] |
| headers="r8c1-t2 r1c2-t2" align="left" | | | headers="r8c1-t2 r1c2-t2" align="left" | | ||
− | [[Configuring | + | [[Configuring a Relational Many-to-Many Mapping (ELUG)|Configuring a Relational Many-to-Many Mapping]] |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r9c1-t2" headers="r1c1-t2" align="left" | | | id="r9c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG) | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Collection Mapping|Aggregate Collection Mapping]] |
| headers="r9c1-t2 r1c2-t2" align="left" | | | headers="r9c1-t2 r1c2-t2" align="left" | | ||
[[Configuring%20a%20Relational%20Aggregate%20Collection%20Mapping%20(ELUG)|Configuring a Relational Aggregate Collection Mapping]] | [[Configuring%20a%20Relational%20Aggregate%20Collection%20Mapping%20(ELUG)|Configuring a Relational Aggregate Collection Mapping]] | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r10c1-t2" headers="r1c1-t2" align="left" | | | id="r10c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Direct Collection Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Collection Mapping|Direct Collection Mapping]] |
| headers="r10c1-t2 r1c2-t2" align="left" | | | headers="r10c1-t2 r1c2-t2" align="left" | | ||
− | [[Configuring | + | [[Configuring a Relational Direct Collection Mapping (ELUG)|Configuring a Relational Direct Collection Mapping]] |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r11c1-t2" headers="r1c1-t2" align="left" | | | id="r11c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Direct Map Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Map Mapping|Direct Map Mapping]] |
| headers="r11c1-t2 r1c2-t2" align="left" | | | headers="r11c1-t2 r1c2-t2" align="left" | | ||
[[Configuring%20a%20Relational%20Direct%20Map%20Mapping%20(ELUG)|Configuring a Relational Direct Map Mapping]] | [[Configuring%20a%20Relational%20Direct%20Map%20Mapping%20(ELUG)|Configuring a Relational Direct Map Mapping]] | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r12c1-t2" headers="r1c1-t2" align="left" | | | id="r12c1-t2" headers="r1c1-t2" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Aggregate Object Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Object Mapping|Aggregate Object Mapping]] |
| headers="r12c1-t2 r1c2-t2" align="left" | | | headers="r12c1-t2 r1c2-t2" align="left" | | ||
− | [[Configuring | + | [[Configuring a Relational Aggregate Object Mapping (ELUG)|Configuring a Relational Aggregate Object Mapping]] |
|} | |} | ||
− | |||
For more information, see the following: | For more information, see the following: | ||
− | |||
* [[Introduction%20to%20Mappings%20(ELUG)|Introduction to Mappings]] | * [[Introduction%20to%20Mappings%20(ELUG)|Introduction to Mappings]] | ||
* [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Introduction to Relational Mappings]] | * [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Introduction to Relational Mappings]] | ||
− | |||
+ | |||
+ | ==Configuring Common Relational Mapping Options== | ||
This table lists the configurable options shared by two or more relational mapping types. | This table lists the configurable options shared by two or more relational mapping types. | ||
<span id="Table 33-2"></span> | <span id="Table 33-2"></span> | ||
− | + | {| class="RuleFormalMax" dir="ltr" title="Common Relational Mapping Options" summary="This table lists the configurable options shared by two or more relational mapping types and categorizes them as Basic and Advanced and indicates if the option can be configured with EclipseLink Workbench, Java, or both." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | |
− | + | ||
− | {| class="RuleFormalMax" dir="ltr" title="Common Relational Mapping Options" summary="This table lists the configurable options shared by two or more relational mapping types and categorizes them as Basic and Advanced and indicates if the option can be configured with | + | |
|- align="left" valign="top" | |- align="left" valign="top" | ||
! id="r1c1-t3" align="left" valign="bottom" | '''Option to Configure''' | ! id="r1c1-t3" align="left" valign="bottom" | '''Option to Configure''' | ||
Line 102: | Line 87: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t3" headers="r1c1-t3" align="left" | | | id="r2c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[#Configuring a Database Field|Database field ]] | |
| headers="r2c1-t3 r1c2-t3" align="left" | | | headers="r2c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 109: | Line 94: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t3" headers="r1c1-t3" align="left" | | | id="r3c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[#Configuring Reference Descriptor|Reference descriptor ]] | |
| headers="r3c1-t3 r1c2-t3" align="left" | | | headers="r3c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 116: | Line 101: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t3" headers="r1c1-t3" align="left" | | | id="r4c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring Container Policy|Container policy ]] | |
| headers="r4c1-t3 r1c2-t3" align="left" | | | headers="r4c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 123: | Line 108: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r5c1-t3" headers="r1c1-t3" align="left" | | | id="r5c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring Method or Direct Field Accessing at the Mapping Level|Method or direct field access]] | |
| headers="r5c1-t3 r1c2-t3" align="left" | | | headers="r5c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 130: | Line 115: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r6c1-t3" headers="r1c1-t3" align="left" | | | id="r6c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring a Default Null Value at the Mapping Level|Default null value ]] | |
| headers="r6c1-t3 r1c2-t3" align="left" | | | headers="r6c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 137: | Line 122: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r7c1-t3" headers="r1c1-t3" align="left" | | | id="r7c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring Read-Only Mappings|Read-only mapping ]] | |
| headers="r7c1-t3 r1c2-t3" align="left" | | | headers="r7c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 144: | Line 129: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r8c1-t3" headers="r1c1-t3" align="left" | | | id="r8c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring Indirection (Lazy Loading)|Indirection (lazy loading)]] | |
| headers="r8c1-t3 r1c2-t3" align="left" | | | headers="r8c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 151: | Line 136: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r9c1-t3" headers="r1c1-t3" align="left" | | | id="r9c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring Private or Independent Relationships|Private or Independent relationships ]] | |
| headers="r9c1-t3 r1c2-t3" align="left" | | | headers="r9c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 158: | Line 143: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r10c1-t3" headers="r1c1-t3" align="left" | | | id="r10c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring Mapping Comments|Mapping comments ]] | |
| headers="r10c1-t3 r1c2-t3" align="left" | | | headers="r10c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 165: | Line 150: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r11c1-t3" headers="r1c1-t3" align="left" | | | id="r11c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring a Serialized Object Converter|Serialized object converter ]] | |
| headers="r11c1-t3 r1c2-t3" align="left" | | | headers="r11c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 172: | Line 157: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r12c1-t3" headers="r1c1-t3" align="left" | | | id="r12c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring a Type Conversion Converter|Type conversion converter ]] | |
| headers="r12c1-t3 r1c2-t3" align="left" | | | headers="r12c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 179: | Line 164: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r13c1-t3" headers="r1c1-t3" align="left" | | | id="r13c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring an Object Type Converter|Object type conversion]] | |
| headers="r13c1-t3 r1c2-t3" align="left" | | | headers="r13c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 186: | Line 171: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r14c1-t3" headers="r1c1-t3" align="left" | | | id="r14c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[Configuring%20a%20Mapping%20(ELUG)#Configuring Bidirectional Relationship|Bidirectional relationship ]] | |
| headers="r14c1-t3 r1c2-t3" align="left" | | | headers="r14c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 193: | Line 178: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r15c1-t3" headers="r1c1-t3" align="left" | | | id="r15c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[#Configuring Batch Reading|Batch reading ]] | |
| headers="r15c1-t3 r1c2-t3" align="left" | | | headers="r15c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 200: | Line 185: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r16c1-t3" headers="r1c1-t3" align="left" | | | id="r16c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[#Configuring Query Key Order|Query key order ]] | |
| headers="r16c1-t3 r1c2-t3" align="left" | | | headers="r16c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 207: | Line 192: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r17c1-t3" headers="r1c1-t3" align="left" | | | id="r17c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[#Configuring Table and Field References (Foreign and Target Foreign Keys)|Table and field references ]] | |
| headers="r17c1-t3 r1c2-t3" align="left" | | | headers="r17c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 214: | Line 199: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r18c1-t3" headers="r1c1-t3" align="left" | | | id="r18c1-t3" headers="r1c1-t3" align="left" | | ||
− | + | [[#Configuring Joining at the Mapping Level|Joining ]] | |
| headers="r18c1-t3 r1c2-t3" align="left" | | | headers="r18c1-t3 r1c2-t3" align="left" | | ||
[[Image:support.gif|Supported]] | [[Image:support.gif|Supported]] | ||
Line 221: | Line 206: | ||
|} | |} | ||
− | |||
+ | |||
+ | ==Configuring a Database Field== | ||
You can associate an object attribute with a database field. | You can associate an object attribute with a database field. | ||
Line 229: | Line 215: | ||
<span id="Table 33-3"></span> | <span id="Table 33-3"></span> | ||
− | |||
− | |||
{| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Database Field" summary="This table summarizes which mappings support Database Field" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | {| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Database Field" summary="This table summarizes which mappings support Database Field" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
! id="r1c1-t4" align="left" valign="bottom" | '''Mapping''' | ! id="r1c1-t4" align="left" valign="bottom" | '''Mapping''' | ||
− | ! id="r1c2-t4" align="left" valign="bottom" | '''[[#How to Configure a Database Field Using Workbench]]''' | + | ! id="r1c2-t4" align="left" valign="bottom" | '''[[#How to Configure a Database Field Using Workbench|Using the Workbench]]''' |
! id="r1c3-t4" align="left" valign="bottom" | '''How to Use Java''' | ! id="r1c3-t4" align="left" valign="bottom" | '''How to Use Java''' | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t4" headers="r1c1-t4" align="left" | | | id="r2c1-t4" headers="r1c1-t4" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Direct-to-Field Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct-to-Field Mapping|Direct-to-Field Mapping]] |
| headers="r2c1-t4 r1c2-t4" align="left" | | | headers="r2c1-t4 r1c2-t4" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 245: | Line 229: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t4" headers="r1c1-t4" align="left" | | | id="r3c1-t4" headers="r1c1-t4" align="left" | | ||
− | [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Direct-to-XMLType Mapping]] | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct-to-XMLType Mapping|Direct-to-XMLType Mapping]] |
| headers="r3c1-t4 r1c2-t4" align="left" | | | headers="r3c1-t4 r1c2-t4" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 251: | Line 235: | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
|} | |} | ||
− | |||
Line 257: | Line 240: | ||
EclipseLink supports the following Java types: | EclipseLink supports the following Java types: | ||
− | |||
* <tt>java.lang</tt><nowiki>: </nowiki><tt>Boolean</tt>, <tt>Float</tt>, <tt>Integer</tt>, <tt>String</tt>, <tt>Double</tt>, <tt>Long</tt>, <tt>Short</tt>, <tt>Byte</tt>, <tt>Byte[ ]</tt>, <tt>Character</tt>, <tt>Character[ ]</tt><nowiki>; all the primitives associated with these classes</nowiki> | * <tt>java.lang</tt><nowiki>: </nowiki><tt>Boolean</tt>, <tt>Float</tt>, <tt>Integer</tt>, <tt>String</tt>, <tt>Double</tt>, <tt>Long</tt>, <tt>Short</tt>, <tt>Byte</tt>, <tt>Byte[ ]</tt>, <tt>Character</tt>, <tt>Character[ ]</tt><nowiki>; all the primitives associated with these classes</nowiki> | ||
* <tt>java.math</tt><nowiki>: </nowiki><tt>BigInteger</tt>, <tt>BigDecimal</tt> | * <tt>java.math</tt><nowiki>: </nowiki><tt>BigInteger</tt>, <tt>BigDecimal</tt> | ||
Line 263: | Line 245: | ||
* <tt>java.util</tt><nowiki>: </nowiki><tt>Date</tt>, <tt>Calendar</tt> | * <tt>java.util</tt><nowiki>: </nowiki><tt>Date</tt>, <tt>Calendar</tt> | ||
− | While executing reads, the mappings in [[#Table 33-6]] perform the simple one-way data conversions that [[#Table 33-4|Type Conversions Provided by Direct-to-Field Mappings]] describes. For two-way or more complex conversions, You must | + | While executing reads, the mappings in the [[#Table 33-6| Relational Mapping Support for Reference Descriptor]] table perform the simple one-way data conversions that the [[#Table 33-4|Type Conversions Provided by Direct-to-Field Mappings]] table describes. For two-way or more complex conversions, You must [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Converters and Transformers|use converters]]). |
− | The mappings in | + | The mappings in this table also allow you to specify a null value. This may be required if primitive types are used in the object, and the database field allows <tt>null</tt> values. For more information, see [[Configuring%20a%20Mapping%20(ELUG)#Configuring a Default Null Value at the Mapping Level|Configuring a Default Null Value at the Mapping Level]]. |
<span id="Table 33-4"></span> | <span id="Table 33-4"></span> | ||
− | '''''Type Conversions Provided by Direct-to-Field Mappings | + | '''''Type Conversions Provided by Direct-to-Field Mappings''''' |
{| class="HRuleFormal" dir="ltr" title="Type Conversions Provided by Direct-to-Field Mappings " summary="This table desribes the direct-to-field mapping type conversions." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows" | {| class="HRuleFormal" dir="ltr" title="Type Conversions Provided by Direct-to-Field Mappings " summary="This table desribes the direct-to-field mapping type conversions." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows" | ||
Line 311: | Line 293: | ||
TIMESTAMP | TIMESTAMP | ||
|} | |} | ||
− | |||
Line 321: | Line 302: | ||
This table lists the supported direct-to-field mapping combinations. | This table lists the supported direct-to-field mapping combinations. | ||
− | |||
Line 413: | Line 393: | ||
<tt>TIMESTAMP</tt> | <tt>TIMESTAMP</tt> | ||
| headers="r14c1-t6 r1c3-t6" align="left" | | | headers="r14c1-t6 r1c3-t6" align="left" | | ||
− | Native SQL or binding gives Calendar timezone.Note: The TIMESTAMP database value has no timezone – the Calendar object provides the local timezone by default. If the database is not in this timezone, you must obtain the database timezone by some other means and update the Calendar object accordingly. For this reason, TIMESTAMPTZ may be a better choice. | + | Native SQL or binding gives Calendar timezone. |
+ | |||
+ | Note: The TIMESTAMP database value has no timezone – the <tt>Calendar</tt> object provides the local timezone by default. If the database is not in this timezone, you must obtain the database timezone by some other means and update the <tt>Calendar</tt>object accordingly. For this reason, TIMESTAMPTZ may be a better choice. | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r15c1-t6" headers="r1c1-t6" align="left" | | | id="r15c1-t6" headers="r1c1-t6" align="left" | | ||
Line 427: | Line 409: | ||
Neither timezone nor milliseconds are stored in the database. | Neither timezone nor milliseconds are stored in the database. | ||
|} | |} | ||
− | |||
Note that some of these mappings result in a loss of precision: avoid these combinations if you require this level of precision. For example, if you create a direct-to-field mapping between a <tt>java.sql.Date</tt> attribute and a <tt>TIMESTAMPTZ</tt> database field, there is no loss of precision. However, if you create a direct-to-field mapping between a <tt>java.sql.Timestamp</tt> attribute and a <tt>DATE</tt> database field, the nanoseconds or milliseconds of the attribute are not stored in the database. | Note that some of these mappings result in a loss of precision: avoid these combinations if you require this level of precision. For example, if you create a direct-to-field mapping between a <tt>java.sql.Date</tt> attribute and a <tt>TIMESTAMPTZ</tt> database field, there is no loss of precision. However, if you create a direct-to-field mapping between a <tt>java.sql.Timestamp</tt> attribute and a <tt>DATE</tt> database field, the nanoseconds or milliseconds of the attribute are not stored in the database. | ||
− | |||
===How to Configure a Database Field Using Workbench=== | ===How to Configure a Database Field Using Workbench=== | ||
− | |||
Use this procedure to select a specific database field for a direct mapping. | Use this procedure to select a specific database field for a direct mapping. | ||
− | |||
# Select the direct mapping attribute in the '''Navigator'''. Its properties appear in the Editor. | # Select the direct mapping attribute in the '''Navigator'''. Its properties appear in the Editor. | ||
− | # Click the '''General''' tab. The General tab appears.<br>''''' | + | # Click the '''General''' tab. The General tab appears.<br>'''''Direct Mapping General Tab, Database Field Option'''''<br>[[Image:mpdtfdfd.gif|Direct Mapping General Tab, Database Field Option]] |
− | + | #Use the '''Database Field''' field to select a field for this direct mapping. You must have previously associated the descriptor with a database table as described in [[Configuring%20a%20Relational%20Descriptor%20(ELUG)#Configuring Associated Tables|Configuring Associated Tables]]. | |
− | Use the '''Database Field''' field to select a field for this direct mapping. You must have previously associated the descriptor with a database table as described in [[Configuring%20a%20Relational%20Descriptor%20(ELUG)|Configuring Associated Tables]]. | + | |
− | + | ||
{| 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" | ||
| align="left" | | | align="left" | | ||
− | + | '''Note'''<nowiki>:</nowiki> For direct-to-field mappings of an aggregate descriptor (see [[Configuring%20a%20Relational%20Descriptor%20(ELUG)|Configuring a Relational Descriptor as a Class or Aggregate Type]]), this field is for display only and cannot be changed. | |
|} | |} | ||
+ | |||
+ | |||
==Configuring Reference Descriptor== | ==Configuring Reference Descriptor== | ||
− | |||
In relational mappings that extend <tt>org.eclipse.persistence.mappings.ForeignReferenceMapping</tt>, attributes reference other EclipseLink descriptors–not the data source. You can select any descriptor in the project. | In relational mappings that extend <tt>org.eclipse.persistence.mappings.ForeignReferenceMapping</tt>, attributes reference other EclipseLink descriptors–not the data source. You can select any descriptor in the project. | ||
Line 458: | Line 435: | ||
<span id="Table 33-6"></span> | <span id="Table 33-6"></span> | ||
− | |||
− | |||
{| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Reference Descriptor" summary="This table summarizes which mappings support Reference Descriptor" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | {| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Reference Descriptor" summary="This table summarizes which mappings support Reference Descriptor" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
! id="r1c1-t8" align="left" valign="bottom" | '''Mapping''' | ! id="r1c1-t8" align="left" valign="bottom" | '''Mapping''' | ||
− | ! id="r1c2-t8" align="left" valign="bottom" | '''[[#How to Configure a Reference Descriptor Using Workbench]]''' | + | ! id="r1c2-t8" align="left" valign="bottom" | '''[[#How to Configure a Reference Descriptor Using Workbench|Using the Workbench]]''' |
! id="r1c3-t8" align="left" valign="bottom" | '''How to Use Java''' | ! id="r1c3-t8" align="left" valign="bottom" | '''How to Use Java''' | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t8" headers="r1c1-t8" align="left" | | | id="r2c1-t8" headers="r1c1-t8" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-One Mapping|One-to-one ]] | |
| headers="r2c1-t8 r1c2-t8" align="left" | | | headers="r2c1-t8 r1c2-t8" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 474: | Line 449: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t8" headers="r1c1-t8" align="left" | | | id="r3c1-t8" headers="r1c1-t8" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Variable One-to-One Mapping|Variable one-to-one ]] | |
| headers="r3c1-t8 r1c2-t8" align="left" | | | headers="r3c1-t8 r1c2-t8" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 481: | Line 456: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t8" headers="r1c1-t8" align="left" | | | id="r4c1-t8" headers="r1c1-t8" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-Many Mapping|One-to-many ]] | |
| headers="r4c1-t8 r1c2-t8" align="left" | | | headers="r4c1-t8 r1c2-t8" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 488: | Line 463: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r5c1-t8" headers="r1c1-t8" align="left" | | | id="r5c1-t8" headers="r1c1-t8" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Many-to-Many Mapping|Many-to-many ]] | |
| headers="r5c1-t8 r1c2-t8" align="left" | | | headers="r5c1-t8 r1c2-t8" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 495: | Line 470: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r6c1-t8" headers="r1c1-t8" align="left" | | | id="r6c1-t8" headers="r1c1-t8" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Collection Mapping|Aggregate collection ]] | |
| headers="r6c1-t8 r1c2-t8" align="left" | | | headers="r6c1-t8 r1c2-t8" align="left" | | ||
[[Image:unsupport.gif|Unsupported.]] | [[Image:unsupport.gif|Unsupported.]] | ||
Line 502: | Line 477: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r7c1-t8" headers="r1c1-t8" align="left" | | | id="r7c1-t8" headers="r1c1-t8" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Object Mapping|Aggregate object ]] | |
| headers="r7c1-t8 r1c2-t8" align="left" | | | headers="r7c1-t8 r1c2-t8" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 508: | Line 483: | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
|} | |} | ||
− | |||
===How to Configure a Reference Descriptor Using Workbench=== | ===How to Configure a Reference Descriptor Using Workbench=== | ||
− | |||
To specify a reference descriptor for a relational mapping, use this procedure. | To specify a reference descriptor for a relational 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 '''General''' tab. The General tab appears.<br>''''' | + | # Click the '''General''' tab. The General tab appears.<br>'''''General Tab, Reference Descriptor Field'''''<br>[[Image:mpgenref.gif|General Tab, Reference Descriptor Field]] |
− | + | # Use the '''Reference Descriptor''' field to select the descriptor referenced by this relationship mapping. | |
− | Use the '''Reference Descriptor''' field to select the descriptor referenced by this relationship 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" | ||
| align="left" | | | align="left" | | ||
− | + | '''Note'''<nowiki>:</nowiki> For aggregate mappings the '''Reference Descriptor''' must be an ''aggregate''. See [[Configuring%20a%20Relational%20Descriptor%20(ELUG)|Configuring a Relational Descriptor as a Class or Aggregate Type]] for more information. | |
− | + | ||
+ | For variable one-to-one mappings, the Reference Descriptor must be an ''interface''. See [[Configuring%20a%20Relational%20Variable%20One-to-One%20Mapping%20(ELUG)|Configuring a Relational Variable One-to-One Mapping]] for more information. | ||
+ | |} | ||
Line 537: | Line 508: | ||
When you generate the deployment XML for your project, the ''mapping'' to the <tt>Employee</tt> class will be included, but not the <tt>Employee</tt> class. | When you generate the deployment XML for your project, the ''mapping'' to the <tt>Employee</tt> class will be included, but not the <tt>Employee</tt> class. | ||
− | + | See Also: | |
− | : [[#Configuring Reference Descriptor]] | + | : [[#Configuring Reference Descriptor|Configuring Reference Descriptor]] |
==Configuring Batch Reading== | ==Configuring Batch Reading== | ||
− | |||
Batch reading can be used in most of the relational mappings. This feature should be used only if it is known that the related objects are always required with the source object. | Batch reading can be used in most of the relational mappings. This feature should be used only if it is known that the related objects are always required with the source object. | ||
Line 550: | Line 520: | ||
<span id="Table 33-7"></span> | <span id="Table 33-7"></span> | ||
− | |||
− | |||
{| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Batch Reading" summary="This table summarizes which mappings support batch reading" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | {| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Batch Reading" summary="This table summarizes which mappings support batch reading" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
! id="r1c1-t10" align="left" valign="bottom" | '''Mapping''' | ! id="r1c1-t10" align="left" valign="bottom" | '''Mapping''' | ||
− | ! id="r1c2-t10" align="left" valign="bottom" | '''[[#How to Configure Batch Reading Using Workbench]''' | + | ! id="r1c2-t10" align="left" valign="bottom" | '''[[#How to Configure Batch Reading Using Workbench|Using the Workbench]]''' |
− | ! id="r1c3-t10" align="left" valign="bottom" | '''[[#How to Configure Batch Reading Using Java]''' | + | ! id="r1c3-t10" align="left" valign="bottom" | '''[[#How to Configure Batch Reading Using Java|Using Java]]''' |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t10" headers="r1c1-t10" align="left" | | | id="r2c1-t10" headers="r1c1-t10" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-One Mapping|One-to-one ]] | |
| headers="r2c1-t10 r1c2-t10" align="left" | | | headers="r2c1-t10 r1c2-t10" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 566: | Line 534: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t10" headers="r1c1-t10" align="left" | | | id="r3c1-t10" headers="r1c1-t10" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-Many Mapping|One-to-many ]] | |
| headers="r3c1-t10 r1c2-t10" align="left" | | | headers="r3c1-t10 r1c2-t10" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 573: | Line 541: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t10" headers="r1c1-t10" align="left" | | | id="r4c1-t10" headers="r1c1-t10" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Many-to-Many Mapping|Many-to-many ]] | |
| headers="r4c1-t10 r1c2-t10" align="left" | | | headers="r4c1-t10 r1c2-t10" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 580: | Line 548: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r5c1-t10" headers="r1c1-t10" align="left" | | | id="r5c1-t10" headers="r1c1-t10" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Collection Mapping|Direct collection ]] | |
| headers="r5c1-t10 r1c2-t10" align="left" | | | headers="r5c1-t10 r1c2-t10" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 587: | Line 555: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r6c1-t10" headers="r1c1-t10" align="left" | | | id="r6c1-t10" headers="r1c1-t10" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Map Mapping|Direct map ]] | |
| headers="r6c1-t10 r1c2-t10" align="left" | | | headers="r6c1-t10 r1c2-t10" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 594: | Line 562: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r7c1-t10" headers="r1c1-t10" align="left" | | | id="r7c1-t10" headers="r1c1-t10" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Object Mapping|Aggregate object ]] | |
| headers="r7c1-t10 r1c2-t10" align="left" | | | headers="r7c1-t10 r1c2-t10" align="left" | | ||
[[Image:unsupport.gif|Unsupported.]] | [[Image:unsupport.gif|Unsupported.]] | ||
Line 600: | Line 568: | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
|} | |} | ||
− | |||
===How to Configure Batch Reading Using Workbench=== | ===How to Configure Batch Reading Using Workbench=== | ||
− | |||
To use batch reading in a relationship mapping, use this procedure: | To use batch reading in a relationship 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 '''General''' tab. The General tab appears.<br>''''' | + | # Click the '''General''' tab. The General tab appears.<br>'''''General Tab, Batch Reading Option'''''<br>[[Image:oogenbat.gif|General Tab, Batch Reading Option]] |
− | + | #To specify that this mapping using batch reading, select the '''Batch Reading''' option. | |
− | To specify that this mapping using batch reading, select the '''Batch Reading''' option. | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
===How to Configure Batch Reading Using Java=== | ===How to Configure Batch Reading Using Java=== | ||
− | |||
This example shows how to use a <tt>DescriptorCustomizer</tt> class to add batch reading to a mapping. | This example shows how to use a <tt>DescriptorCustomizer</tt> class to add batch reading to a mapping. | ||
− | |||
<span id="Example 33-1"></span> | <span id="Example 33-1"></span> | ||
''''' Query Optimization Using Batching''''' | ''''' Query Optimization Using Batching''''' | ||
+ | <source lang="java"> | ||
public void customize(ClassDescriptor descriptor) { | public void customize(ClassDescriptor descriptor) { | ||
OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); | OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); | ||
− | phoneNumbersMapping = | + | phoneNumbersMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("phones"); |
− | + | ||
phoneNumbersMapping.useBatchReading(); | phoneNumbersMapping.useBatchReading(); | ||
} | } | ||
− | + | </source> | |
==Configuring Query Key Order== | ==Configuring Query Key Order== | ||
− | |||
You can configure EclipseLink to maintain collections in order by query key. | You can configure EclipseLink to maintain collections in order by query key. | ||
Line 641: | Line 598: | ||
<span id="Table 33-8"></span> | <span id="Table 33-8"></span> | ||
− | |||
− | |||
{| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Query Key Order" summary="This table summarizes which mappings support Query Key Order" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | {| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Query Key Order" summary="This table summarizes which mappings support Query Key Order" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
! id="r1c1-t11" align="left" valign="bottom" | '''Mapping''' | ! id="r1c1-t11" align="left" valign="bottom" | '''Mapping''' | ||
− | ! id="r1c2-t11" align="left" valign="bottom" | '''[[#How to Configure Query Key Order Using Workbench]]''' | + | ! id="r1c2-t11" align="left" valign="bottom" | '''[[#How to Configure Query Key Order Using Workbench|Using the Workbench]]''' |
− | ! id="r1c3-t11" align="left" valign="bottom" | '''[[#How to Configure Query Key Order Using Java]]''' | + | ! id="r1c3-t11" align="left" valign="bottom" | '''[[#How to Configure Query Key Order Using Java|Using Java]]''' |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t11" headers="r1c1-t11" align="left" | | | id="r2c1-t11" headers="r1c1-t11" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Many-to-Many Mapping|Many-to-many ]] | |
| headers="r2c1-t11 r1c2-t11" align="left" | | | headers="r2c1-t11 r1c2-t11" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 657: | Line 612: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t11" headers="r1c1-t11" align="left" | | | id="r3c1-t11" headers="r1c1-t11" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-Many Mapping|One-to-many ]] | |
| headers="r3c1-t11 r1c2-t11" align="left" | | | headers="r3c1-t11 r1c2-t11" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 664: | Line 619: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t11" headers="r1c1-t11" align="left" | | | id="r4c1-t11" headers="r1c1-t11" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Collection Mapping|Aggregate collection ]] | |
| headers="r4c1-t11 r1c2-t11" align="left" | | | headers="r4c1-t11 r1c2-t11" align="left" | | ||
[[Image:unsupport.gif|Unsupported.]] | [[Image:unsupport.gif|Unsupported.]] | ||
Line 670: | Line 625: | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
|} | |} | ||
− | |||
===How to Configure Query Key Order Using Workbench=== | ===How to Configure Query Key Order Using Workbench=== | ||
− | |||
To specify the order of a mapping's query keys, use this procedure: | To specify the order of a mapping's query keys, 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 '''Ordering''' tab. The Ordering tab appears.<br>''''' | + | # Click the '''Ordering''' tab. The Ordering tab appears.<br>'''''Ordering Tab'''''<br>[[Image:onetomany_coll_ord.gif|Ordering Tab]] |
− | # Complete the | + | # Complete the '''Ordering''' options on the tab. |
− | + | ||
− | + | ||
{| class="HRuleInformal" dir="ltr" title="This table identifies each field on the tab." summary="This table identifies each field on the tab." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows" | {| class="HRuleInformal" dir="ltr" title="This table identifies each field on the tab." summary="This table identifies each field on the tab." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows" | ||
Line 690: | Line 640: | ||
| id="r2c1-t12" headers="r1c1-t12" align="left" | '''Query Key''' | | id="r2c1-t12" headers="r1c1-t12" align="left" | '''Query Key''' | ||
| headers="r2c1-t12 r1c2-t12" align="left" | | | headers="r2c1-t12 r1c2-t12" align="left" | | ||
− | Specify the query key to order by. Click '''Add''' to add query keys to, or '''Remove''' to remove query keys from the ordering operation.Click '''Up''' or '''Down''' to change the sort order of selected query keys. | + | Specify the query key to order by. |
+ | |||
+ | Click '''Add''' to add query keys to, or '''Remove''' to remove query keys from the ordering operation. | ||
+ | |||
+ | Click '''Up''' or '''Down''' to change the sort order of selected query keys. | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t12" headers="r1c1-t12" align="left" | '''Order''' | | id="r3c1-t12" headers="r1c1-t12" align="left" | '''Order''' | ||
| headers="r3c1-t12 r1c2-t12" align="left" | Specify if EclipseLink orders the selected query key in '''Ascending''' or '''Descending''' (alphabetical) order. | | headers="r3c1-t12 r1c2-t12" align="left" | Specify if EclipseLink orders the selected query key in '''Ascending''' or '''Descending''' (alphabetical) order. | ||
|} | |} | ||
− | |||
===How to Configure Query Key Order Using Java=== | ===How to Configure Query Key Order Using Java=== | ||
− | |||
This example shows how to use the <tt>DescriptorCustomizer</tt> class to add complex ordering to a mapping. | This example shows how to use the <tt>DescriptorCustomizer</tt> class to add complex ordering to a mapping. | ||
− | |||
<span id="'Example 33-2"></span> | <span id="'Example 33-2"></span> | ||
− | '''' Configuring Query Key Order''''' | + | ''''' Configuring Query Key Order''''' |
+ | <source lang="java"> | ||
public void customize(ClassDescriptor descriptor) { | public void customize(ClassDescriptor descriptor) { | ||
OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); | OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); | ||
− | phoneNumbersMapping = | + | phoneNumbersMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("phones"); |
− | + | ||
phoneNumbersMapping.addAscendingOrdering("areaCode"); | phoneNumbersMapping.addAscendingOrdering("areaCode"); | ||
− | ExpressionBuilder phone = | + | ExpressionBuilder phone = phoneNumbersMapping.getSelectionQuery().getExpressionBuilder(); |
− | + | ||
phoneNumbersMapping.getSelectionQuery().addOrdering( | phoneNumbersMapping.getSelectionQuery().addOrdering( | ||
phone.get("type").toUpperCase().ascending()); | phone.get("type").toUpperCase().ascending()); | ||
} | } | ||
− | + | </source> | |
− | + | ||
{| 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" | ||
| align="left" | | | align="left" | | ||
− | '''Note:''' You can provide the same functionality by using a descriptor amendment method (see [[Customizing%20the%20EclipseLink%20Application%20(ELUG)|Using the Descriptor Amendment Methods]]). | + | '''Note:''' You can provide the same functionality by using a descriptor amendment method (see [[Customizing%20the%20EclipseLink%20Application%20(ELUG)#Using the Descriptor Amendment Methods|Using the Descriptor Amendment Methods]]). |
|} | |} | ||
Line 750: | Line 699: | ||
This table summarizes which relational mappings support this option. | This table summarizes which relational mappings support this option. | ||
− | |||
− | |||
− | |||
{| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Table Reference" summary="This table summarizes which mappings support Table Reference" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | {| class="RuleFormal" dir="ltr" title="Relational Mapping Support for Table Reference" summary="This table summarizes which mappings support Table Reference" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
! id="r1c1-t15" align="left" valign="bottom" | '''Mapping''' | ! id="r1c1-t15" align="left" valign="bottom" | '''Mapping''' | ||
− | ! id="r1c2-t15" align="left" valign="bottom" | '''[[#How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Workbench]]''' | + | ! id="r1c2-t15" align="left" valign="bottom" | '''[[#How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Workbench|Using the Workbench]]''' |
− | ! id="r1c3-t15" align="left" valign="bottom" | '''[[#How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Java]]''' | + | ! id="r1c3-t15" align="left" valign="bottom" | '''[[#How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Java|Using Java]]''' |
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t15" headers="r1c1-t15" align="left" | | | id="r2c1-t15" headers="r1c1-t15" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-One Mapping|One-to-one ]] | |
| headers="r2c1-t15 r1c2-t15" align="left" | | | headers="r2c1-t15 r1c2-t15" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 768: | Line 714: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t15" headers="r1c1-t15" align="left" | | | id="r3c1-t15" headers="r1c1-t15" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#One-to-Many Mapping|One-to-many ]] | |
| headers="r3c1-t15 r1c2-t15" align="left" | | | headers="r3c1-t15 r1c2-t15" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 775: | Line 721: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t15" headers="r1c1-t15" align="left" | | | id="r4c1-t15" headers="r1c1-t15" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Many-to-Many Mapping|Many-to-many ]] | |
| headers="r4c1-t15 r1c2-t15" align="left" | | | headers="r4c1-t15 r1c2-t15" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 782: | Line 728: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r5c1-t15" headers="r1c1-t15" align="left" | | | id="r5c1-t15" headers="r1c1-t15" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Aggregate Collection Mapping|Aggregate collection ]] | |
| headers="r5c1-t15 r1c2-t15" align="left" | | | headers="r5c1-t15 r1c2-t15" align="left" | | ||
[[Image:unsupport.gif|Unsupported.]] | [[Image:unsupport.gif|Unsupported.]] | ||
Line 789: | Line 735: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r6c1-t15" headers="r1c1-t15" align="left" | | | id="r6c1-t15" headers="r1c1-t15" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Collection Mapping|Direct collection ]] | |
| headers="r6c1-t15 r1c2-t15" align="left" | | | headers="r6c1-t15 r1c2-t15" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 796: | Line 742: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r7c1-t15" headers="r1c1-t15" align="left" | | | id="r7c1-t15" headers="r1c1-t15" align="left" | | ||
− | + | [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Map Mapping|Direct map ]] | |
| headers="r7c1-t15 r1c2-t15" align="left" | | | headers="r7c1-t15 r1c2-t15" align="left" | | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
Line 802: | Line 748: | ||
[[Image:support.gif|Supported.]] | [[Image:support.gif|Supported.]] | ||
|} | |} | ||
− | |||
Using Workbench, you can either import this table from your database or create it. If you import tables from the database (see [[Using%20Workbench%20(ELUG)|Importing Tables from a Database]]), EclipseLink creates references that correspond to existing database constraints (if supported by the driver). You can also define references in EclipseLink without creating similar constraints on the database. | Using Workbench, you can either import this table from your database or create it. If you import tables from the database (see [[Using%20Workbench%20(ELUG)|Importing Tables from a Database]]), EclipseLink creates references that correspond to existing database constraints (if supported by the driver). You can also define references in EclipseLink without creating similar constraints on the database. | ||
− | |||
===How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Workbench=== | ===How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Workbench=== | ||
− | |||
To specify a table for a mapping reference, use this procedure: | To specify a table for a mapping reference, 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 '''Table Reference''' tab. The Reference tab appears.<br>''''' | + | # Click the '''Table Reference''' tab. The Reference tab appears.<br>'''''Table Reference Tab, Table Reference Field'''''<br>[[Image:onetomany_tab_ref.gif|Table Reference Tab, Table Reference Field]] |
− | # Complete the fields on the | + | # Complete the fields on the Table Reference tab. |
Use the following information to select the field references on the tab: | Use the following information to select the field references on the tab: | ||
− | |||
Line 844: | Line 785: | ||
− | + | See Also: | |
− | + | : [[#Configuring Table and Field References (Foreign and Target Foreign Keys)|Configuring Table and Field References (Foreign and Target Foreign Keys)]] | |
− | : [[Configuring Table and Field References (Foreign and Target Foreign Keys)]] | + | |
− | + | ||
===How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Java=== | ===How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Java=== | ||
− | |||
Use the <tt>addTargetForeignKeyFieldName</tt> method (and pass the name of the field name of the target foreign key and the source of the primary key in the source table) to specify foreign key information. | Use the <tt>addTargetForeignKeyFieldName</tt> method (and pass the name of the field name of the target foreign key and the source of the primary key in the source table) to specify foreign key information. | ||
Line 861: | Line 799: | ||
<span id="Example 33-3"></span> | <span id="Example 33-3"></span> | ||
''''' Adding Complex Join to a Mapping''''' | ''''' Adding Complex Join to a Mapping''''' | ||
+ | <source lang="java"> | ||
public void customize(ClassDescriptor descriptor) { | public void customize(ClassDescriptor descriptor) { | ||
OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); | OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); | ||
− | phoneNumbersMapping = | + | phoneNumbersMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("cellPhones"); |
− | + | ||
− | ExpressionBuilder phone = | + | ExpressionBuilder phone = phoneNumbersMapping.getSelectionQuery().getExpressionBuilder(); |
− | + | ||
phoneNumbersMapping.addTargetForeignKeyFieldName("PHONE.EMP_ID", "EMP.ID"); | phoneNumbersMapping.addTargetForeignKeyFieldName("PHONE.EMP_ID", "EMP.ID"); | ||
Line 876: | Line 813: | ||
and(phone.getField("PHONE.TYPE').equal("CELL"))); | and(phone.getField("PHONE.TYPE').equal("CELL"))); | ||
} | } | ||
− | + | </source> | |
− | + | ||
{| 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" | ||
| align="left" | | | align="left" | | ||
− | '''Note:''' You can provide the same functionality by using a descriptor amendment method (see [[Customizing%20the%20EclipseLink%20Application%20(ELUG)|Using the Descriptor Amendment Methods]]). | + | '''Note:''' You can provide the same functionality by using a descriptor amendment method (see [[Customizing%20the%20EclipseLink%20Application%20(ELUG)#Using the Descriptor Amendment Methods|Using the Descriptor Amendment Methods]]). |
|} | |} | ||
+ | |||
+ | |||
==Configuring Joining at the Mapping Level== | ==Configuring Joining at the Mapping Level== | ||
− | |||
EclipseLink supports configuring an inner or outer join at the mapping level for a <tt>ForeignReferenceMapping</tt>. When a class that owns the mapping is read, the EclipseLink runtime will always get the class and the target of the reference mapping with one database hit. | EclipseLink supports configuring an inner or outer join at the mapping level for a <tt>ForeignReferenceMapping</tt>. When a class that owns the mapping is read, the EclipseLink runtime will always get the class and the target of the reference mapping with one database hit. | ||
− | Use this feature only if the target object is ''always'' required with the source object, or when indirection (lazy loading) is ''not'' used. For more information, see [[Introduction%20to%20Mappings%20(ELUG)|Indirection (Lazy Loading)]]. | + | Use this feature only if the target object is ''always'' required with the source object, or when indirection (lazy loading) is ''not'' used. For more information, see [[Introduction%20to%20Mappings%20(ELUG)#Indirection (Lazy Loading)|Indirection (Lazy Loading)]]. |
− | You can also configure join reading at the query level. For more information, see [[Introduction%20to%20EclipseLink%20Queries%20(ELUG)|Join Reading and Object-Level Read Queries]]. | + | You can also configure join reading at the query level. For more information, see [[Introduction%20to%20EclipseLink%20Queries%20(ELUG)#Join Reading and Object-Level Read Queries|Join Reading and Object-Level Read Queries]]. |
For more information about joins, see [[Introduction%20to%20EclipseLink%20Expressions%20(ELUG)|Expressions for Joining and Complex Relationships]]. | For more information about joins, see [[Introduction%20to%20EclipseLink%20Expressions%20(ELUG)|Expressions for Joining and Complex Relationships]]. | ||
− | |||
===How to Configure Joining at the Mapping Level Using Workbench=== | ===How to Configure Joining at the Mapping Level Using Workbench=== | ||
− | |||
To use joining in a relationship mapping, use this procedure: | To use joining in a relationship 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 '''General''' tab. The General tab appears.<br><span id="'Figure 33-6"></span>'''' General Tab, Use Joining Option'''''<br> | + | # Click the '''General''' tab. The General tab appears.<br><span id="'Figure 33-6"></span>'''''General Tab, Use Joining Option'''''<br>[[Image:oogenjoi.gif|General Tab, Use Joining Option]] |
− | [[Image:oogenjoi.gif|General Tab, Use Joining Option]] | + | # To use joining with this relationship, select the '''Use Joining''' option. |
− | + | See Also: | |
+ | : [[#Configuring Joining at the Mapping Level|Configuring Joining at the Mapping Level]] | ||
− | |||
− | |||
===How to Configure Joining at the Mapping Level Using Java=== | ===How to Configure Joining at the Mapping Level Using Java=== | ||
− | |||
This example shows how to use the <tt>DescriptorCustomizer</tt> class to add complex join at the mapping level. | This example shows how to use the <tt>DescriptorCustomizer</tt> class to add complex join at the mapping level. | ||
Line 916: | Line 848: | ||
<span id="Example 33-4"></span> | <span id="Example 33-4"></span> | ||
''''' Adding Join at the Mapping Level''''' | ''''' Adding Join at the Mapping Level''''' | ||
+ | <source lang="java"> | ||
public void customize(ClassDescriptor descriptor) { | public void customize(ClassDescriptor descriptor) { | ||
OneToManyMapping addressMapping = new OneToManyMapping(); | OneToManyMapping addressMapping = new OneToManyMapping(); | ||
− | addressMapping = | + | addressMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("address"); |
− | + | ||
addressMapping.useJoining(); | addressMapping.useJoining(); | ||
... | ... | ||
} | } | ||
− | + | </source> | |
− | + | ||
{| 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" | ||
| align="left" | | | align="left" | | ||
− | '''Note:''' You can provide the same functionality by using a descriptor amendment method (see [[Customizing%20the%20EclipseLink%20Application%20(ELUG)|Using the Descriptor Amendment Methods]]). | + | '''Note:''' You can provide the same functionality by using a descriptor amendment method (see [[Customizing%20the%20EclipseLink%20Application%20(ELUG)#Using the Descriptor Amendment Methods|Using the Descriptor Amendment Methods]]). |
|} | |} | ||
Line 939: | Line 870: | ||
[[Category: EclipseLink User's Guide]] | [[Category: EclipseLink User's Guide]] | ||
− | [[Category: | + | [[Category: Release 1]] |
[[Category: Task]] | [[Category: Task]] | ||
+ | [[Category: ORM]] |
Latest revision as of 09:42, 20 May 2009
Contents
For information on how to create EclipseLink mappings, see Creating a Mapping.
This table lists the types of relational mappings that you can configure and provides a cross-reference to the type-specific chapter that lists the configurable options supported by that type.
If you are creating... | See... |
---|---|
For more information, see the following:
Configuring Common Relational Mapping Options
This table lists the configurable options shared by two or more relational mapping types.
Option to Configure | Workbench | Java |
---|---|---|
Configuring a Database Field
You can associate an object attribute with a database field.
This table summarizes which relational mappings support this option.
Mapping | Using the Workbench | How to Use Java |
---|---|---|
When choosing the database field, you must consider Java and database field type compatibility.
EclipseLink supports the following Java types:
- java.lang: Boolean, Float, Integer, String, Double, Long, Short, Byte, Byte[ ], Character, Character[ ]; all the primitives associated with these classes
- java.math: BigInteger, BigDecimal
- java.sql: Date, Time, Timestamp
- java.util: Date, Calendar
While executing reads, the mappings in the Relational Mapping Support for Reference Descriptor table perform the simple one-way data conversions that the Type Conversions Provided by Direct-to-Field Mappings table describes. For two-way or more complex conversions, You must use converters).
The mappings in this table also allow you to specify a null value. This may be required if primitive types are used in the object, and the database field allows null values. For more information, see Configuring a Default Null Value at the Mapping Level.
Type Conversions Provided by Direct-to-Field Mappings
Java type | Database type |
---|---|
Integer, Float, Double, Byte, Short, BigDecimal, BigInteger, int, float, double, byte, short |
NUMBER, NUMERIC, DECIMAL, FLOAT, DOUBLE, INT, SMALLINT, BIT, BOOLEAN |
Boolean, boolean |
BOOLEAN, BIT, SMALLINT, NUMBER, NUMERIC, DECIMAL, FLOAT, DOUBLE, INT |
String |
VARCHAR, CHAR, VARCHAR2, CLOB, TEXT, LONG, LONG VARCHAR, MEMOThe following types apply only to Oracle9: NVARCHAR2, NCLOB, NCHAR |
byte[ ] |
BLOB, LONG RAW, IMAGE, RAW, VARBINARY, BINARY, LONG VARBINARY |
Time |
TIME |
java.sql.Date |
DATE |
Timestamp, java.util.Date, Calendar |
TIMESTAMP |
Support for oracle.sql.TimeStamp
EclipseLink provides additional support for mapping Java date and time data types to Oracle Database DATE, TIMESTAMP, and TIMESTAMPTZ data types when you use the Oracle JDBC driver with Oracle9i Database Server or later and the Oracle9Platform in EclipseLink.
In a direct-to-field mapping, you are not required to specify the database type of the field value; EclipseLink determines the appropriate data type conversion.
This table lists the supported direct-to-field mapping combinations.
Supported Oracle Database Date and Time Direct-to-Field Mappings
Java Type | Database Type | Description |
---|---|---|
java.sql.Time |
TIMESTAMP |
Full bidirectional support. |
TIMESTAMPTZ |
Full bidirectional support. | |
DATE |
Full bidirectional support. | |
java.sql.Date |
TIMESTAMP |
Full bidirectional support. |
TIMESTAMPTZ |
Full bidirectional support. | |
DATE |
Full bidirectional support. | |
java.sql.Timestamp |
TIMESTAMP |
Full bidirectional support. |
TIMESTAMPTZ |
Full bidirectional support. | |
DATE |
Nanoseconds are not stored in the database. | |
java.util.Date |
TIMESTAMP |
Full bidirectional support. |
TIMESTAMPTZ |
Full bidirectional support. | |
DATE |
Milliseconds are not stored in the database. | |
java.util.Calendar |
TIMESTAMP |
Native SQL or binding gives Calendar timezone. Note: The TIMESTAMP database value has no timezone – the Calendar object provides the local timezone by default. If the database is not in this timezone, you must obtain the database timezone by some other means and update the Calendarobject accordingly. For this reason, TIMESTAMPTZ may be a better choice. |
TIMESTAMPTZ |
Native SQL or binding stores timezone; standard SQL is based on the local timezone. | |
DATE |
Neither timezone nor milliseconds are stored in the database. |
Note that some of these mappings result in a loss of precision: avoid these combinations if you require this level of precision. For example, if you create a direct-to-field mapping between a java.sql.Date attribute and a TIMESTAMPTZ database field, there is no loss of precision. However, if you create a direct-to-field mapping between a java.sql.Timestamp attribute and a DATE database field, the nanoseconds or milliseconds of the attribute are not stored in the database.
How to Configure a Database Field Using Workbench
Use this procedure to select a specific database field for a direct mapping.
- Select the direct mapping attribute in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
Direct Mapping General Tab, Database Field Option - Use the Database Field field to select a field for this direct mapping. You must have previously associated the descriptor with a database table as described in Configuring Associated Tables.
Note: For direct-to-field mappings of an aggregate descriptor (see Configuring a Relational Descriptor as a Class or Aggregate Type), this field is for display only and cannot be changed. |
Configuring Reference Descriptor
In relational mappings that extend org.eclipse.persistence.mappings.ForeignReferenceMapping, attributes reference other EclipseLink descriptors–not the data source. You can select any descriptor in the project.
This table summarizes which relational mappings support this option.
Mapping | Using the Workbench | How to Use Java |
---|---|---|
How to Configure a Reference Descriptor Using Workbench
To specify a reference descriptor for a relational mapping, use this procedure.
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
General Tab, Reference Descriptor Field - Use the Reference Descriptor field to select the descriptor referenced by this relationship mapping.
Note: For aggregate mappings the Reference Descriptor must be an aggregate. See Configuring a Relational Descriptor as a Class or Aggregate Type for more information. For variable one-to-one mappings, the Reference Descriptor must be an interface. See Configuring a Relational Variable One-to-One Mapping for more information. |
You can specify a reference descriptor that is not in the current Workbench project. For example, to create a mapping to an Employee class that does not exist in the current project, do the following:
- Add the Employee class to your current project. See Working with Projects.
- Create the relationship mapping to the Employee descriptor.
- Deactivate the Employee descriptor. See Active and Inactive Descriptors.
When you generate the deployment XML for your project, the mapping to the Employee class will be included, but not the Employee class.
See Also:
Configuring Batch Reading
Batch reading can be used in most of the relational mappings. This feature should be used only if it is known that the related objects are always required with the source object.
This table summarizes which relational mappings support this option.
Mapping | Using the Workbench | Using Java |
---|---|---|
How to Configure Batch Reading Using Workbench
To use batch reading in a relationship mapping, use this procedure:
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
General Tab, Batch Reading Option - To specify that this mapping using batch reading, select the Batch Reading option.
How to Configure Batch Reading Using Java
This example shows how to use a DescriptorCustomizer class to add batch reading to a mapping.
Query Optimization Using Batching
public void customize(ClassDescriptor descriptor) { OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); phoneNumbersMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("phones"); phoneNumbersMapping.useBatchReading(); }
Configuring Query Key Order
You can configure EclipseLink to maintain collections in order by query key.
This table summarizes which relational mappings support this option.
Mapping | Using the Workbench | Using Java |
---|---|---|
How to Configure Query Key Order Using Workbench
To specify the order of a mapping's query keys, use this procedure:
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the Ordering tab. The Ordering tab appears.
Ordering Tab - Complete the Ordering options on the tab.
Field | Description |
---|---|
Query Key |
Specify the query key to order by. Click Add to add query keys to, or Remove to remove query keys from the ordering operation. Click Up or Down to change the sort order of selected query keys. |
Order | Specify if EclipseLink orders the selected query key in Ascending or Descending (alphabetical) order. |
How to Configure Query Key Order Using Java
This example shows how to use the DescriptorCustomizer class to add complex ordering to a mapping.
Configuring Query Key Order
public void customize(ClassDescriptor descriptor) { OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); phoneNumbersMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("phones"); phoneNumbersMapping.addAscendingOrdering("areaCode"); ExpressionBuilder phone = phoneNumbersMapping.getSelectionQuery().getExpressionBuilder(); phoneNumbersMapping.getSelectionQuery().addOrdering( phone.get("type").toUpperCase().ascending()); }
Note: You can provide the same functionality by using a descriptor amendment method (see Using the Descriptor Amendment Methods). |
Configuring Table and Field References (Foreign and Target Foreign Keys)
A foreign key is a combination of one or more database columns that reference a unique key, usually the primary key, in another table. Foreign keys can be any number of fields (similar to a primary key), all of which are treated as a unit. A foreign key and the parent key it references must have the same number and type of fields.
Mappings that extend org.eclipse.persistence.mappings.ForeignReferenceMapping use foreign keys to find information in the database so that the target object(s) can be instantiated. For example, if every Employee has an attribute address that contains an instance of Address (which has its own descriptor and table) then, the one-to-one mapping for the address attribute would specify foreign key information to find an Address for a particular Employee.
EclipseLink classifies foreign keys into two categories in mappings–foreign keys and target foreign keys:
- In a foreign key, the key is found in the table associated with the mapping's own descriptor. For example, an Employee foreign key to ADDRESS would be in the EMPLOYEE table.
- In a target foreign key, the reference is from the target object's table back to the key from the mapping's descriptor's table. For example, the ADDRESS table would have a foreign key to EMPLOYEE.
Caution: Make sure you fully understand the distinction between foreign key and target foreign key before defining a mapping. |
The table reference is the database table that contains the foreign key references.
This table summarizes which relational mappings support this option.
Mapping | Using the Workbench | Using Java |
---|---|---|
Using Workbench, you can either import this table from your database or create it. If you import tables from the database (see Importing Tables from a Database), EclipseLink creates references that correspond to existing database constraints (if supported by the driver). You can also define references in EclipseLink without creating similar constraints on the database.
How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Workbench
To specify a table for a mapping reference, use this procedure:
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the Table Reference tab. The Reference tab appears.
Table Reference Tab, Table Reference Field - Complete the fields on the Table Reference tab.
Use the following information to select the field references on the tab:
Field | Description |
---|---|
Table Reference | Select an existing table, or click New to create a new table reference. |
Source and Target Field |
Click Add to create new foreign key reference. To delete an existing key pair reference, select the Source and Target fields and click Remove. |
Source Field | Select the database field from the source table for this foreign key reference. |
Target Field | Select the database field from the target table for this foreign key reference. |
Target Foreign Key | Specify whether or not the reference is from the target object's table back to the key from the mapping's descriptor's table. |
See Also:
How to Configure Table and Field References (Foreign and Target Foreign Keys) Using Java
Use the addTargetForeignKeyFieldName method (and pass the name of the field name of the target foreign key and the source of the primary key in the source table) to specify foreign key information.
For composite source primary keys, use the addTargetForeignKeyFieldName method for each of the fields that comprise the primary key.
This esxample shows how to use the DescriptorCustomizer class to add complex join to a mapping.
Adding Complex Join to a Mapping
public void customize(ClassDescriptor descriptor) { OneToManyMapping phoneNumbersMapping = new OneToManyMapping(); phoneNumbersMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("cellPhones"); ExpressionBuilder phone = phoneNumbersMapping.getSelectionQuery().getExpressionBuilder(); phoneNumbersMapping.addTargetForeignKeyFieldName("PHONE.EMP_ID", "EMP.ID"); phoneNumbersMapping.getSelectionQuery( phone.getField("PHONE.EMP_ID").equal(phone.getParameter("EMP.ID"). and(phone.getField("PHONE.TYPE').equal("CELL"))); }
Note: You can provide the same functionality by using a descriptor amendment method (see Using the Descriptor Amendment Methods). |
Configuring Joining at the Mapping Level
EclipseLink supports configuring an inner or outer join at the mapping level for a ForeignReferenceMapping. When a class that owns the mapping is read, the EclipseLink runtime will always get the class and the target of the reference mapping with one database hit.
Use this feature only if the target object is always required with the source object, or when indirection (lazy loading) is not used. For more information, see Indirection (Lazy Loading).
You can also configure join reading at the query level. For more information, see Join Reading and Object-Level Read Queries.
For more information about joins, see Expressions for Joining and Complex Relationships.
How to Configure Joining at the Mapping Level Using Workbench
To use joining in a relationship mapping, use this procedure:
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
General Tab, Use Joining Option
General Tab, Use Joining Option - To use joining with this relationship, select the Use Joining option.
See Also:
How to Configure Joining at the Mapping Level Using Java
This example shows how to use the DescriptorCustomizer class to add complex join at the mapping level.
Adding Join at the Mapping Level
public void customize(ClassDescriptor descriptor) { OneToManyMapping addressMapping = new OneToManyMapping(); addressMapping = (OneToManyMapping)descriptor.getMappingForAttributeName("address"); addressMapping.useJoining(); ... }
Note: You can provide the same functionality by using a descriptor amendment method (see Using the Descriptor Amendment Methods). |