Oracle® TopLink Developer's Guide 10g Release 3 (10.1.3.1.0) Part Number B28218-01 |
|
|
View PDF |
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
Table 47-2 lists the configurable options shared by two or more object-relational mapping types.
For more information, see the following:
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 |
---|---|---|---|
|
Basic |
||
|
Basic |
||
|
Basic |
||
|
Basic |
||
"Configuring Read-Only Mappings" |
Basic |
||
"Configuring Method Accessing" |
Advanced |
||
|
Advanced |
||
"Configuring Container Policy" |
Advanced |
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.
Table 47-3 Mapping Support for Reference Class
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.
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.
Table 47-4 Mapping Support for Attribute Name
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.
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.
Table 47-5 Mapping Support for Field Name
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.
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.
Table 47-6 Mapping Support for Structure Name
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
.