Skip to main content

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.

Jump to: navigation, search

Configuring an Object-Relational Data Type Mapping (ELUG)

Revision as of 12:41, 30 November 2007 by Unnamed Poltroon (Talk)

This section describes how to configure an object-relational data type mapping. For information on how to configure EclipseLink mappings options common to two or more mapping types, see Configuring a Mapping For information on how to create EclipseLink mappings, see Creating a Mapping.

Introduction to Object-Relational Data Type Mapping Configuration

This table lists the types of object-relational data type mappings that you can configure and provides a cross-reference to the type-specific chapter that lists the configurable options supported by that type.

Configuring Object-Relational Data Type Mappings

For more information, see the following:

Configuring Common Object-Relational Data Type Mapping Options

This table lists the configurable options shared by two or more object-relational data type mapping types. In addition to the configurable options described here, you must also configure the options described for the specific object-relational data type mapping types (see Introduction to Object-Relational Data Type Mappings (ELUG)#Object-Relational Data Type Mapping Types), as shown in Configuring Object-Relational Data Type Mappings.


Common Options for Object-Relational Data Type Mappings

Table 50-4 Mapping Support for Attribute Name {| class="RuleFormal" dir="ltr" title="Mapping Support for Attribute Name" summary="This table summarizes which mappings support ort for Attribute Name" width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all" |- align="left" valign="top" ! id="r1c1-t5" align="left" valign="bottom" | Mapping ! id="r1c2-t5" align="left" valign="bottom" | How to Use Workbench ! id="r1c3-t5" align="left" valign="bottom" | [[#How to Configure Attribute Name Using Java] |- align="left" valign="top" | id="r2c1-t5" headers="r1c1-t5" align="left" | Object-relational data type structure mapping (see [Introduction%20to%20Object-Relational%20Data%20Type%20Mappings%20(ELUG)#Object-Relational Data Type Structure Mapping]) | headers="r2c1-t5 r1c2-t5" align="left" | Supported | headers="r2c1-t5 r1c3-t5" align="left" | Supported. |- align="left" valign="top" | id="r3c1-t5" headers="r1c1-t5" align="left" | Object-relational data type reference mapping (see [Introduction%20to%20Object-Relational%20Data%20Type%20Mappings%20(ELUG)#Object-Relational Data Type Reference Mapping]) | headers="r3c1-t5 r1c2-t5" align="left" | Supported | headers="r3c1-t5 r1c3-t5" align="left" | Supported. |- align="left" valign="top" | id="r4c1-t5" headers="r1c1-t5" align="left" | Object-relational data type array mapping (see [Introduction%20to%20Object-Relational%20Data%20Type%20Mappings%20(ELUG)#Object-Relational Data Type Array Mapping]) | headers="r4c1-t5 r1c2-t5" align="left" | Supported | headers="r4c1-t5 r1c3-t5" align="left" | Supported. |- align="left" valign="top" | id="r5c1-t5" headers="r1c1-t5" align="left" | Object-relational data type object array mapping (see [Introduction%20to%20Object-Relational%20Data%20Type%20Mappings%20(ELUG)#Object-Relational Data Type Object Array Mapping]) | headers="r5c1-t5 r1c2-t5" align="left" | Supported | headers="r5c1-t5 r1c3-t5" align="left" | Supported. |- align="left" valign="top" | id="r6c1-t5" headers="r1c1-t5" align="left" | Object-relational data type nested table mapping (see [Introduction%20to%20Object-Relational%20Data%20Type%20Mappings%20(ELUG)#Object-Relational Data Type Nested Table Mapping]) | headers="r6c1-t5 r1c2-t5" align="left" | Supported | headers="r6c1-t5 r1c3-t5" align="left" | Supported. |}

How to Configure Attribute Name Using Java

Use org.eclipse.persistence.mappings.DatabaseMapping method setAttributeName to specify the name of the attribute being mapped. [[#Example 50-2] shows how to use this method with a ReferenceMapping that maps the manager attribute of the Employee class.

Example 50-2 Configuring Attribute Name in Java

public void customize(ClassDescriptor descriptor) {
ReferenceMapping managerMapping = new new ReferenceMapping(); managerMapping.setReferenceClass("Employee.class"); managerMapping.setAttributeName("manager"); // set attribute name // add this mapping to descriptor descriptor.addMapping (managerMapping); }  

For more information, see the EclipseLink API Reference.


Configuring Field Name

All object-relational data type 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 50-5] summarizes which object-relational data type mappings support this option.

Table 50-5 Mapping Support for Field Name

How to Configure Field Name Using Java

Use the object-relational data type mapping method setFieldName to specify the database field to which the attribute is mapped. [[#Example 50-3] shows how to use this method with an ObjectArrayMapping that maps the Employee class attribute phone to database field name PHONE_NUMBER.

Example 50-3 Configuring Field Name in Java

public void customize(ClassDescriptor descriptor) { ObjectArrayMapping phonesMapping = new ObjectArrayMapping(); phonesMapping.setReferenceClass("Employee.class"); phonesMapping.setAttributeName("phone"); phonesMapping.setFieldName("PHONE_NUMBER"); // set field name // add this mapping to descriptor descriptor.addMapping (phonesMapping); }  For more information, see the [olinkSRC%20JITAR EclipseLink API Reference].  


Configuring Structure Name

Certain object-relational data type 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. This table summarizes which object-relational data type mappings support this option.  

Table 50-6 Mapping Support for Structure Name

How to Configure Structure Name Using Java

Use the object-relational data type mapping method setStructureName to specify the structure of the attribute being mapped. [[#Example 50-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 50-4 Configuring Structure Name in Java public void customize(ClassDescriptor descriptor) { ObjectArrayMapping phonesMapping = new ObjectArrayMapping(); phonesMapping.setReferenceClass("Employee.class"); phonesMapping.setAttributeName("phones"); phonesMapping.setFieldName("PHONE_NUMBERS"); phonesMapping.setStructureName("PHONE_ARRAY_TYPE"); // set structure name // add this mapping to descriptor descriptor.addMapping (phonesMapping); } For more information, see the [olinkSRC%20JITAR EclipseLink API Reference].



Copyright Statement

Back to the top