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

47 Configuring an Object-Relational Mapping

This chapter describes how to configure an object-relational mapping.

Table 47-1 lists the types of object-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.

Table 47-1 Configuring Object-Relational Mappings

If you are creating... See Also...

Object-Relational Structure Mapping


Chapter 48, "Configuring an Object-Relational Structure Mapping"


Object-Relational Reference Mapping


Chapter 49, "Configuring an Object-Relational Reference Mapping"


Object-Relational Array Mapping


Chapter 50, "Configuring an Object-Relational Array Mapping"


Object-Relational Object Array Mapping


Chapter 51, "Configuring an Object-Relational Object Array Mapping"


Object-Relational Nested Table Mapping


Chapter 52, "Configuring an Object-Relational Nested Table Mapping"



Table 47-2 lists the configurable options shared by two or more object-relational mapping types.

For more information, see the following:

Configuring Common Object-Relational Mapping Options

Table 47-2 lists the configurable options shared by two or more object-relational mapping types. In addition to the configurable options described here, you must also configure the options described for the specific Object-Relational Mapping Types, as shown in Table 47-1.

Table 47-2 Common Options for Object-Relational Mappings

Option Type TopLink Workbench
Java

"Configuring Reference Class"


Basic

Unsupported
Supported

"Configuring Attribute Name"


Basic

Unsupported
Supported

"Configuring Field Name"


Basic

Unsupported
Supported

"Configuring Structure Name"


Basic

Unsupported
Supported

"Configuring Read-Only Mappings"


Basic

Unsupported
Supported

"Configuring Method Accessing"


Advanced

Unsupported
Supported

"Configuring Indirection"


Advanced

Unsupported
Supported

"Configuring Container Policy"


Advanced

Unsupported
Supported

Configuring Reference Class

When mapping an attribute that involves a relationship to another class, you must specify the reference class–the Java class to which the mapped attribute refers.

Table 47-3 summarizes which object-relational mappings support this option.

Using Java

Use oracle.toplink.mappings.ForeignReferenceMapping method setReferenceClass to specify the target class of the attribute being mapped.

Example 47-1 shows how to use this method with a ReferenceMapping that maps the manager attribute of the Employee class.

Example 47-1 Configuring Reference Class in Java

ReferenceMapping managerMapping = new new ReferenceMapping();
managerMapping.setReferenceClass("Employee.class");
managerMapping.setAttributeName("manager");

Configuring Attribute Name

All object-relational mappings map an attribute in a Java object to field in the database. The attribute name is the name of the attribute being mapped. The name is as specified in the reference class (see "Configuring Reference Class").

Table 47-4 summarizes which object-relational mappings support this option.

Using Java

Use oracle.toplink.mappings.DatabaseMapping method setAttributeName to specify the name of the attribute being mapped.

Example 47-2 shows how to use this method with a ReferenceMapping that maps the manager attribute of the Employee class.

Example 47-2 Configuring Attribute Name in Java

ReferenceMapping managerMapping = new new ReferenceMapping();
managerMapping.setReferenceClass("Employee.class");
managerMapping.setAttributeName("manager");

Configuring Field Name

All object-relational mappings require the name of database field to which their specified attribute is mapped. This field name can be the column name of a database table or the name of a field in an object type created on the database.

Table 47-5 summarizes which object-relational mappings support this option.

Using Java

Use the object-relational mapping method setFieldName to specify the database field to which the attribute is mapped.

Example 47-3 shows how to use this method with an ObjectArrayMapping that maps the Employee class attribute phone to database field name PHONE_NUMBER.

Example 47-3 Configuring Field Name in Java

ObjectArrayMapping phonesMapping = new ObjectArrayMapping();
managerMapping.setReferenceClass("Employee.class");
phonesMapping.setAttributeName("phone");
phonesMapping.setFieldName("PHONE_NUMBER");

Configuring Structure Name

Certain object-relational mappings require the specification of the data type or structure name of the field being mapped. The structure name is the name of the array or table type that defines the field.

Table 47-6 summarizes which object-relational mappings support this option.

Using Java

Use the object-relational mapping method setStructureName to specify the structure of the attribute being mapped.

Example 47-4 shows how to use this method with an ObjectArrayMapping that maps the Employee class attribute phones to database field name PHONE_NUMBERS of type PHONE_ARRAY_TYPE.

Example 47-4 Configuring Structure Name in Java

ObjectArrayMapping phonesMapping = new ObjectArrayMapping();
managerMapping.setReferenceClass("Employee.class");
phonesMapping.setAttributeName("phones");
phonesMapping.setFieldName("PHONE_NUMBERS");
phonesMapping.setStructureName("PHONE_ARRAY_TYPE");