Skip Headers
Oracle® TopLink Developer's Guide
10g Release 3 (10.1.3.1.0)

Part Number B28218-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

46 Understanding Object-Relational Mappings

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

Do not confuse object-relational mappings with relational mappings (see "Understanding Relational Mappings"). 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 mappings with specialized object-relational databases optimized to support object-relational data source representations.

This chapter describes:

Object-Relational Mapping Types

TopLink supports the object-relational mappings listed in Table 46-1.

These mappings allow for an object model to persist in an object-relational data model. Currently, TopLink Workbench does not support object-relational mappings–they must be defined in code or through amendment methods.

Table 46-1 TopLink Object-Relationship Mapping Types

Type Description Type TopLink Workbench Java

"Object-Relational Structure Mapping"


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

Advanced

Unsupported
Supported

"Object-Relational Reference Mapping"


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

Advanced

Unsupported
Supported

"Object-Relational Array Mapping"


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

Advanced

Unsupported
Supported

"Object-Relational Object Array Mapping"


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

Advanced

Unsupported
Supported

"Object-Relational Nested Table Mapping"


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

Advanced

Unsupported
Supported

Object-Relational Structure Mapping

In an object-relational 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:

TopLink 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 support of the database).

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

Object-Relational Reference Mapping

In an object-relational 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.

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

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

Object-Relational Array Mapping

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

TopLink maps arrays of primitive data types with the ArrayMapping class. An array mapping maps to object-relational 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 Object Array Mapping").

The object-relational 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 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 Array Mapping" for more information.

Object-Relational Object Array Mapping

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

TopLink 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 Object Array Mapping" for more information.

Object-Relational 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).

TopLink maps nested tables with the NestedTableMapping class. It represents a collection of object references in Java. Because of the object-relational 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. TopLink supports mapping a nested table of REF types only. TopLink does not support nested tables of basic or other structured data types–use array (see "Object-Relational Array Mapping") or object array (see "Object-Relational Object Array Mapping") mappings instead.

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