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 "Introduction to Object-Relational Data Type Mappings (ELUG)"

m (New page: <div style="float:right;border:1px solid #000000;padding:5px">__TOC__ Related Topics</div> An object-r...)
 
m (Object-Relational Data Type Nested Table Mapping)
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
An object-relational data type mapping transforms certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases (such as Oracle Database). Object-relational data type mappings let you map an object model into an object-relational data type data model.
 
An object-relational data type mapping transforms certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases (such as Oracle Database). Object-relational data type mappings let you map an object model into an object-relational data type data model.
  
Do not confuse object-relational data type mappings with relational mappings (see [[Introduction%20to%20Relational%20Mappings%20(ELUG)|Transformation Mapping]]). A relational mapping transforms any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings let you map an object model into a relational data model. In general, you can use relational mappings with any supported relational database. You can only use object-relational data type mappings with specialized object-relational data type databases optimized to support object-relational data type data source representations.
+
Do not confuse object-relational data type mappings with relational mappings (see [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Transformation Mapping|Transformation Mapping]]). A relational mapping transforms any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings let you map an object model into a relational data model. In general, you can use relational mappings with any supported relational database. You can only use object-relational data type mappings with specialized object-relational data type databases optimized to support object-relational data type data source representations.
  
 
For information on mapping concepts and features common to more than one type of EclipseLink mappings, see [[Introduction%20to%20Mappings%20(ELUG)|Introduction to Mappings]].
 
For information on mapping concepts and features common to more than one type of EclipseLink mappings, see [[Introduction%20to%20Mappings%20(ELUG)|Introduction to Mappings]].
  
 
+
EclipseLink supports the following object-relational data type mappings. These mappings allow for an object model to persist in an object-relational data type data model. The Workbench does not support object-relational data type mappings–they must be defined in code or through amendment methods.
 
+
==Object-Relational Data Type Mapping Types==
+
 
+
EclipseLink supports the object-relational data type mappings listed in [[#Table 45-1|EclipseLink Object-Relationship Mapping Types]].
+
 
+
These mappings allow for an object model to persist in an object-relational data type data model. The Workbench does not support object-relational data type mappings–they must be defined in code or through amendment methods.
+
  
  
 
<span id="Table 45-1"></span>
 
<span id="Table 45-1"></span>
''''' EclipseLink Object-Relationship Mapping Types'''''
 
 
 
{| class="RuleFormalWideMax" dir="ltr" title="EclipseLink Object-Relationship Mapping Types" summary="This table describes the object relationship mapping types." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
{| class="RuleFormalWideMax" dir="ltr" title="EclipseLink Object-Relationship Mapping Types" summary="This table describes the object relationship mapping types." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
|- align="left" valign="top"
 
|- align="left" valign="top"
Line 27: Line 19:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r2c1-t2" headers="r1c1-t2" align="left" |
 
| id="r2c1-t2" headers="r1c1-t2" align="left" |
Object-relational data type structure mapping (see [[#Object-Relational Data Type Structure Mapping]])
+
[[#Object-Relational Data Type Structure Mapping|Object-relational data type structure mapping]]
 
| headers="r2c1-t2 r1c2-t2" align="left" |
 
| headers="r2c1-t2 r1c2-t2" align="left" |
 
Map to object-relational data type aggregate structures (the <tt>Struct</tt> type in JDBC and the <tt>OBJECT</tt> type in Oracle Database''i'')
 
Map to object-relational data type aggregate structures (the <tt>Struct</tt> type in JDBC and the <tt>OBJECT</tt> type in Oracle Database''i'')
Line 36: Line 28:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r3c1-t2" headers="r1c1-t2" align="left" |
 
| id="r3c1-t2" headers="r1c1-t2" align="left" |
Object-relational data type reference mapping (see [[#Object-Relational Data Type Reference Mapping]])
+
[[#Object-Relational Data Type Reference Mapping|Object-relational data type reference mapping ]]
 
| headers="r3c1-t2 r1c2-t2" align="left" |
 
| headers="r3c1-t2 r1c2-t2" align="left" |
 
Map to object-relational data type references (the <tt>Ref</tt> type in JDBC and the <tt>REF</tt> type in Oracle Database)
 
Map to object-relational data type references (the <tt>Ref</tt> type in JDBC and the <tt>REF</tt> type in Oracle Database)
Line 45: Line 37:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r4c1-t2" headers="r1c1-t2" align="left" |
 
| id="r4c1-t2" headers="r1c1-t2" align="left" |
Object-relational data type array mapping (see [[#Object-Relational Data Type Array Mapping]])
+
[[#Object-Relational Data Type Array Mapping|Object-relational data type array mapping ]]
 
| headers="r4c1-t2 r1c2-t2" align="left" |
 
| headers="r4c1-t2 r1c2-t2" align="left" |
 
Map a collection of primitive data to object-relational data type array data types (the <tt>Array</tt> type in JDBC and the <tt>VARRAY</tt> type in Oracle Database).
 
Map a collection of primitive data to object-relational data type array data types (the <tt>Array</tt> type in JDBC and the <tt>VARRAY</tt> type in Oracle Database).
Line 54: Line 46:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r5c1-t2" headers="r1c1-t2" align="left" |
 
| id="r5c1-t2" headers="r1c1-t2" align="left" |
Object-relational data type object array mapping (see [[#Object-Relational Data Type Object Array Mapping]])
+
[[#Object-Relational Data Type Object Array Mapping|Object-relational data type object array mapping ]]
 
| headers="r5c1-t2 r1c2-t2" align="left" |
 
| headers="r5c1-t2 r1c2-t2" align="left" |
 
Map to object-relational data type array data types (the <tt>Array</tt> type in JDBC and the <tt>VARRAY</tt> type in Oracle Database).
 
Map to object-relational data type array data types (the <tt>Array</tt> type in JDBC and the <tt>VARRAY</tt> type in Oracle Database).
Line 63: Line 55:
 
|- align="left" valign="top"
 
|- align="left" valign="top"
 
| id="r6c1-t2" headers="r1c1-t2" align="left" |
 
| id="r6c1-t2" headers="r1c1-t2" align="left" |
Object-relational data type nested table mapping (see [[#Object-Relational Data Type Nested Table Mapping]]
+
[[#Object-Relational Data Type Nested Table Mapping|Object-relational data type nested table mapping ]]
 
| headers="r6c1-t2 r1c2-t2" align="left" |
 
| headers="r6c1-t2 r1c2-t2" align="left" |
 
Map to object-relational data type nested tables (the <tt>Array</tt> type in JDBC and the <tt>NESTED</tt> <tt>TABLE</tt> type in Oracle Database)
 
Map to object-relational data type nested tables (the <tt>Array</tt> type in JDBC and the <tt>NESTED</tt> <tt>TABLE</tt> type in Oracle Database)
Line 75: Line 67:
  
 
===Object-Relational Data Type Structure Mapping===
 
===Object-Relational Data Type Structure Mapping===
 
 
In an object-relational data type data model, '''structures''' are user-defined data types or object types. This is similar to a Java class–it defines attributes or fields in which each attribute is one of the following:
 
In an object-relational data type data model, '''structures''' are user-defined data types or object types. This is similar to a Java class–it defines attributes or fields in which each attribute is one of the following:
 
 
* A primitive data type.
 
* A primitive data type.
 
* Another structure.
 
* Another structure.
Line 84: Line 74:
 
EclipseLink maps nested structures with the <tt>StructureMapping</tt> class. The structure mapping supports null values and shared aggregates without requiring additional settings (because of the object-relational data type support of the database).
 
EclipseLink maps nested structures with the <tt>StructureMapping</tt> class. The structure mapping supports null values and shared aggregates without requiring additional settings (because of the object-relational data type support of the database).
  
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Structure%20Mapping%20(ELUG)|Chapter 46, "Configuring an Object-Relational Data Type Structure Mapping"]] for more information.
+
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Structure%20Mapping%20(ELUG)|Configuring an Object-Relational Data Type Structure Mapping]] for more information.
  
  
  
 
===Object-Relational Data Type Reference Mapping===
 
===Object-Relational Data Type Reference Mapping===
 
 
In an object-relational data type data model, structures reference each other through '''refs'''–not through foreign keys (as in a traditional data model). Refs are based on the target structure's <tt>ObjectID</tt>. They represent an object reference in Java.
 
In an object-relational data type data model, structures reference each other through '''refs'''–not through foreign keys (as in a traditional data model). Refs are based on the target structure's <tt>ObjectID</tt>. They represent an object reference in Java.
  
 
EclipseLink maps refs with the <tt>ReferenceMapping</tt> class. The reference mapping does not require foreign key information (because of the object-relational data type support of the database).
 
EclipseLink maps refs with the <tt>ReferenceMapping</tt> class. The reference mapping does not require foreign key information (because of the object-relational data type support of the database).
  
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Reference%20Mapping%20(ELUG)|Chapter 47, "Configuring an Object-Relational Data Type Reference Mapping"]] for more information.
+
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Reference%20Mapping%20(ELUG)|Configuring an Object-Relational Data Type Reference Mapping]] for more information.
 +
 
  
===Object-Relational Data Type Array Mapping===
 
  
 +
===Object-Relational Data Type Array Mapping===
 
In an object-relational data type data model, structures can contain '''arrays''' (collections of other data types). These arrays can contain primitive data types or collections of other structures.
 
In an object-relational data type data model, structures can contain '''arrays''' (collections of other data types). These arrays can contain primitive data types or collections of other structures.
  
EclipseLink maps arrays of primitive data types with the <tt>ArrayMapping</tt> class. An array mapping maps to object-relational data type array data types (the <tt>Array</tt> type in JDBC and the <tt>VARRAY</tt> type in Oracle Database). To map a collection of aggregate structures, use an object array mapping (see [[#Object-Relational Data Type Object Array Mapping]]).
+
EclipseLink maps arrays of primitive data types with the <tt>ArrayMapping</tt> class. An array mapping maps to object-relational data type array data types (the <tt>Array</tt> type in JDBC and the <tt>VARRAY</tt> type in Oracle Database). To map a collection of aggregate structures, use an object array mapping (see [[#Object-Relational Data Type Object Array Mapping|Object-Relational Data Type Object Array Mapping]]).
  
The object-relational data type database stores the arrays with their parent structure in the same table. To store information in a separate table from the parent structure's table, use a nested table mapping (see [[#Object-Relational Data Type Nested Table Mapping]]).
+
The object-relational data type database stores the arrays with their parent structure in the same table. To store information in a separate table from the parent structure's table, use a nested table mapping (see [[#Object-Relational Data Type Nested Table Mapping|Object-Relational Data Type Nested Table Mapping]]).
  
 
All elements in the array must be the same data type. The number of elements in an array controls the size of the array. An Oracle Database allows arrays of variable sizes (the <tt>VARRAY</tt> type).
 
All elements in the array must be the same data type. The number of elements in an array controls the size of the array. An Oracle Database allows arrays of variable sizes (the <tt>VARRAY</tt> type).
  
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Array%20Mapping%20(ELUG)|Chapter 48, "Configuring an Object-Relational Data Type Array Mapping"]] for more information.
+
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Array%20Mapping%20(ELUG)|Configuring an Object-Relational Data Type Array Mapping]] for more information.
  
  
  
 
===Object-Relational Data Type Object Array Mapping===
 
===Object-Relational Data Type Object Array Mapping===
 
 
In an object-relational data type data model, structures can contain ''arrays'' (collections of other data types). These arrays can contain primitive data types or collections of other structures.
 
In an object-relational data type data model, structures can contain ''arrays'' (collections of other data types). These arrays can contain primitive data types or collections of other structures.
  
Line 118: Line 107:
 
You must associate this mapping to an attribute in the parent class.
 
You must associate this mapping to an attribute in the parent class.
  
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Object%20Array%20Mapping%20(ELUG)|Chapter 49, "Configuring an Object-Relational Data Type Object Array Mapping"]] for more information.
+
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Object%20Array%20Mapping%20(ELUG)|Configuring an Object-Relational Data Type Object Array Mapping]] for more information.
  
  
  
 
===Object-Relational Data Type Nested Table Mapping===
 
===Object-Relational Data Type Nested Table Mapping===
 
 
'''Nested table''' types model an unordered set of elements. These elements may be built-in or user-defined types. You can view a nested table as a single-column table or, if the nested table is an object type, as a multicolumn table (with a column for each attribute of the object type).
 
'''Nested table''' types model an unordered set of elements. These elements may be built-in or user-defined types. You can view a nested table as a single-column table or, if the nested table is an object type, as a multicolumn table (with a column for each attribute of the object type).
  
 
EclipseLink maps nested tables with the <tt>NestedTableMapping</tt> class. It represents a collection of object references in Java. Because of the object-relational data type support of the database, nested table mapping does not require foreign key information (as with a one-to-many mapping) or a relational table (as with a many-to-many mapping).
 
EclipseLink maps nested tables with the <tt>NestedTableMapping</tt> class. It represents a collection of object references in Java. Because of the object-relational data type support of the database, nested table mapping does not require foreign key information (as with a one-to-many mapping) or a relational table (as with a many-to-many mapping).
  
Typically, nested tables represent a one-to-many or many-to-many relationship of references to another independent structure. They support querying and joining better than the <tt>VARRAY</tt> types that are in-lined to the parent table. EclipseLink supports mapping a nested table of <tt>REF</tt> types only. EclipseLink does not support nested tables of basic or other structured data types–use array (see [[#Object-Relational Data Type Array Mapping]) or object array (see [[#Object-Relational Data Type Object Array Mapping]) mappings instead.
+
Typically, nested tables represent a one-to-many or many-to-many relationship of references to another independent structure. They support querying and joining better than the <tt>VARRAY</tt> types that are in-lined to the parent table. EclipseLink supports mapping a nested table of <tt>REF</tt> types only. EclipseLink does not support nested tables of basic or other structured data types–use array (see [[#Object-Relational Data Type Array Mapping|Object-Relational Data Type Array Mapping]]) or object array (see [[#Object-Relational Data Type Object Array Mapping|Object-Relational Data Type Object Array Mapping]]) mappings instead.
  
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Nested%20Table%20Mapping%20(ELUG)|Chapter 51, "Configuring an Object-Relational Data Type Nested Table Mappin] for more information.
+
See [[Configuring%20an%20Object-Relational%20Data%20Type%20Nested%20Table%20Mapping%20(ELUG)|Configuring an Object-Relational Data Type Nested Table Mapping]] for more information.
  
  
Line 138: Line 126:
  
 
[[Category: EclipseLink User's Guide]]
 
[[Category: EclipseLink User's Guide]]
[[Category: Draft]]
+
[[Category: Release 1]]
 
[[Category: Concept]]
 
[[Category: Concept]]
 +
[[Category: ORM]]

Latest revision as of 07:54, 20 August 2008

An object-relational data type mapping transforms certain object data member types to structured data source representations optimized for storage in specialized object-relational data type databases (such as Oracle Database). Object-relational data type mappings let you map an object model into an object-relational data type data model.

Do not confuse object-relational data type mappings with relational mappings (see Transformation Mapping). A relational mapping transforms any object data member type to a corresponding relational database (SQL) data source representation in any supported relational database. Relational mappings let you map an object model into a relational data model. In general, you can use relational mappings with any supported relational database. You can only use object-relational data type mappings with specialized object-relational data type databases optimized to support object-relational data type data source representations.

For information on mapping concepts and features common to more than one type of EclipseLink mappings, see Introduction to Mappings.

EclipseLink supports the following object-relational data type mappings. These mappings allow for an object model to persist in an object-relational data type data model. The Workbench does not support object-relational data type mappings–they must be defined in code or through amendment methods.


Type of Mapping Description EclipseLink Workbench Java

Object-relational data type structure mapping

Map to object-relational data type aggregate structures (the Struct type in JDBC and the OBJECT type in Oracle Databasei)

Unsupported

Supported

Object-relational data type reference mapping

Map to object-relational data type references (the Ref type in JDBC and the REF type in Oracle Database)

Unsupported

Supported

Object-relational data type array mapping

Map a collection of primitive data to object-relational data type array data types (the Array type in JDBC and the VARRAY type in Oracle Database).

Unsupported

Supported

Object-relational data type object array mapping

Map to object-relational data type array data types (the Array type in JDBC and the VARRAY type in Oracle Database).

Unsupported

Supported

Object-relational data type nested table mapping

Map to object-relational data type nested tables (the Array type in JDBC and the NESTED TABLE type in Oracle Database)

Unsupported

Supported


Object-Relational Data Type Structure Mapping

In an object-relational data type data model, structures are user-defined data types or object types. This is similar to a Java class–it defines attributes or fields in which each attribute is one of the following:

  • A primitive data type.
  • Another structure.
  • Reference to another structure.

EclipseLink maps nested structures with the StructureMapping class. The structure mapping supports null values and shared aggregates without requiring additional settings (because of the object-relational data type support of the database).

See Configuring an Object-Relational Data Type Structure Mapping for more information.


Object-Relational Data Type Reference Mapping

In an object-relational data type data model, structures reference each other through refs–not through foreign keys (as in a traditional data model). Refs are based on the target structure's ObjectID. They represent an object reference in Java.

EclipseLink maps refs with the ReferenceMapping class. The reference mapping does not require foreign key information (because of the object-relational data type support of the database).

See Configuring an Object-Relational Data Type Reference Mapping for more information.


Object-Relational Data Type Array Mapping

In an object-relational data type data model, structures can contain arrays (collections of other data types). These arrays can contain primitive data types or collections of other structures.

EclipseLink maps arrays of primitive data types with the ArrayMapping class. An array mapping maps to object-relational data type array data types (the Array type in JDBC and the VARRAY type in Oracle Database). To map a collection of aggregate structures, use an object array mapping (see Object-Relational Data Type Object Array Mapping).

The object-relational data type database stores the arrays with their parent structure in the same table. To store information in a separate table from the parent structure's table, use a nested table mapping (see Object-Relational Data Type Nested Table Mapping).

All elements in the array must be the same data type. The number of elements in an array controls the size of the array. An Oracle Database allows arrays of variable sizes (the VARRAY type).

See Configuring an Object-Relational Data Type Array Mapping for more information.


Object-Relational Data Type Object Array Mapping

In an object-relational data type data model, structures can contain arrays (collections of other data types). These arrays can contain primitive data types or collections of other structures.

EclipseLink maps arrays of structures with the ObjectArrayMapping class. An object array mapping defines a collection-aggregated relationship, in which the target objects share the same row as the source object.

You must associate this mapping to an attribute in the parent class.

See Configuring an Object-Relational Data Type Object Array Mapping for more information.


Object-Relational Data Type Nested Table Mapping

Nested table types model an unordered set of elements. These elements may be built-in or user-defined types. You can view a nested table as a single-column table or, if the nested table is an object type, as a multicolumn table (with a column for each attribute of the object type).

EclipseLink maps nested tables with the NestedTableMapping class. It represents a collection of object references in Java. Because of the object-relational data type support of the database, nested table mapping does not require foreign key information (as with a one-to-many mapping) or a relational table (as with a many-to-many mapping).

Typically, nested tables represent a one-to-many or many-to-many relationship of references to another independent structure. They support querying and joining better than the VARRAY types that are in-lined to the parent table. EclipseLink supports mapping a nested table of REF types only. EclipseLink does not support nested tables of basic or other structured data types–use array (see Object-Relational Data Type Array Mapping) or object array (see Object-Relational Data Type Object Array Mapping) mappings instead.

See Configuring an Object-Relational Data Type Nested Table Mapping for more information.



Copyright Statement

Back to the top