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 "Configuring a Relational Direct Map Mapping (ELUG)"

m (Introduction to Relational Direct Map Mapping Configuration)
m (Introduction to Relational Direct Map Mapping Configuration)
Line 113: Line 113:
  
  
 +
This example shows how to create a direct map mapping and add it to a descriptor using Java code.
 +
 +
<span id="Example 36-1"></span>
 +
''''' Direct Map Mapping'''''
 +
 +
<pre>
 +
public void customize(ClassDescriptor descriptor) {
 +
    DirectMapMapping mapping = new DirectMapMapping(); 
 +
 +
    // configure mapping
 +
    ...
 +
 +
    // add mapping to descriptor
 +
    descriptor.addMapping(mapping);
 +
}
 +
</pre>
  
 
For more information, see the following:
 
For more information, see the following:
Line 118: Line 134:
 
* [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Map Mapping|Direct Map Mapping]]
 
* [[Introduction%20to%20Relational%20Mappings%20(ELUG)#Direct Map Mapping|Direct Map Mapping]]
 
* [[Configuring%20a%20Relational%20Mapping%20(ELUG)|Configuring a Relational Mapping]]
 
* [[Configuring%20a%20Relational%20Mapping%20(ELUG)|Configuring a Relational Mapping]]
 +
* [[Creating%20and%20Configuring%20Mappings%20(ELUG)|Creating and Configuring Mappings]]
  
 
For information on using JPA to configure direct map mappings, see [[Using%20EclipseLink%20JPA%20Extensions%20(ELUG)#How to Use the @BasicMap Annotation|How to Use the @BasicMap Annotation]].
 
For information on using JPA to configure direct map mappings, see [[Using%20EclipseLink%20JPA%20Extensions%20(ELUG)#How to Use the @BasicMap Annotation|How to Use the @BasicMap Annotation]].

Revision as of 12:11, 30 November 2007


This section describes the various components that you must configure in order to use a relational direct map 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.

Configurable Options for Relational Direct Map Mapping lists the configurable options for a relational direct map mapping.


Introduction to Relational Direct Map Mapping Configuration

This table lists the configurable options for a relational direct map mapping.


Configurable Options for Relational Direct Map Mapping

Option Workbench Java

Target table (see Configuring Target Table)

Supported

Supported

Direct value field (see #Configuring Direct Value Field)

Supported

Supported

Direct key field (see #Configuring Direct Key Field)

Supported

Supported

Method or direct field access (see Configuring a Type Conversion Converter)

Supported

Supported

Read-only mapping (see Configuring Read-Only Mappings)

Supported

Supported

Batch reading (see Configuring Batch Reading)

Supported

Supported

Indirection (lazy loading) (see Configuring Mapping Comments)

Supported

Supported

Container policy (see Configuring Mapping Comments)

Supported

Supported

Mapping comments (see Configuring Mapping Comments)

Supported

Supported

Key converters (see #Configuring Key Converters)

Supported

Supported

Value converters (see #Configuring Value Converters)

Supported

Supported

Table and field references (see Configuring Joining at the Mapping Level)

Supported

Supported


This example shows how to create a direct map mapping and add it to a descriptor using Java code.

Direct Map Mapping

public void customize(ClassDescriptor descriptor) { 
    DirectMapMapping mapping = new DirectMapMapping();  

    // configure mapping
    ... 

    // add mapping to descriptor
    descriptor.addMapping(mapping);
}

For more information, see the following:

For information on using JPA to configure direct map mappings, see How to Use the @BasicMap Annotation.

Configuring Direct Value Field

The direct value field in the reference table stores the primitive data value of the map value. If the value's object value and database value are different types, use a converter (see #Configuring Value Converters).


How to Configure Direct Value Fields Using Workbench

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.
  2. Click the General tab. The General tab appears.
    Figure 43-1 General Tab, Direct Value Field
    General Tab, Direct Value Field

Use the Direct Value Field list to select the field from the Target Table table that contains the object of the direct map mapping.

See Also

#Configuring Direct Value Field


How to Configure Direct Value Fields Using Java

Use the DirectMapMapping method setDirectFieldName to set the direct fields for your mapping.

For more information about the available methods for DirectMapMapping, see the [EclipseLink API Reference.

Configuring Direct Key Field

The direct key field in the reference table stores the primitive data value of the map key. If the key's object value and database value are different types, use a converter (see #Configuring Key Converters).


How to Configure Direct Key Field Using Workbench

To specify the direct key field in the reference table, use this procedure.

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.
  2. Click the General tab. The General tab appears.
    Figure 43-2 General Tab, Direct Key Field
    General Tab, Direct Key Field

Use the Direct Key Field list to select the key from the Target Table table that contains the object of the direct map mapping.

See Also

#Configuring Direct Key Field
#Configuring Key Converters

How to Configure Direct Key Field Using Java

Use the DirectMapMapping method setDirectKeyFieldName to set the direct key field for your mapping.

For more information about the available methods for DirectMapMapping, see the EclipseLink API Reference.


Configuring Key Converters

If the key's object value and database value are different types, use a converter. EclipseLink supports the following key converters:


How to Configure Key Converters Using Workbench

Use this procedure to specify the converter for a direct map mapping key:

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.
  2. Click the Converter tab. The Converter tab appears.
  3. Click the Key Converter tab. The Key Converter tab appears.
    Converter Tab, Key Converter Subtab
    Converter Tab, Key Converter Subtab
  4. Select the appropriate [topicid:keyConverter Key Converter].


Converter Description
No Converter Do not use a Key Converter for this mapping.
Serialized Object Converter

See Configuring a Serialized Object Converter.

Type Conversion Converter

See Configuring a Type Conversion Converter.

Object Type Converter

See Configuring an Object Type Converter.


See Also

#Configuring Key Converters
#Configuring Direct Key Field

How to Configure Key Converters Using Java

You can configure whether or not to allow null values using the DirectMapMapping method setKeyConverter.

For more information about the available methods for DirectMapMapping, see the EclipseLink API Reference.

Configuring Value Converters

If the value's object value and database value are different types, use a converter. EclipseLink supports the following value converters:


How to Configure Value Converters Using Workbench

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.
  2. Click the Converter tab. The Converter tab appears.
  3. Click the Value Converter tab. The Value Converter tab appears.
    Converter Tab, Value Converter Subtab
    Converter Tab, Value Converter Subtab
  4. Select the appropriate Value Converter.


Converter Description
No Converter Do not use a Value Converter for this mapping.
Serialized Object Converter

See Configuring a Serialized Object Converter.

Type Conversion Converter

See Configuring a Type Conversion Converter.

Object Type Converter

See Configuring an Object Type Converter.


See Also

#Configuring Value Converters



Copyright Statement

Back to the top