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.
Configuring a Relational Direct Map Mapping (ELUG)
Contents
For information on how to create EclipseLink mappings, see Creating a Mapping.
This table lists the configurable options for a relational direct map mapping.
Option | Workbench | Java |
---|---|---|
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
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
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.
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.
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the General tab. The General tab appears.
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.
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:
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the Converter tab. The Converter tab appears.
- Click the Key Converter tab. The Key Converter tab appears.
Converter Tab, Key Converter Subtab - Select the appropriate Key Converter.
Converter | Description |
---|---|
No Converter | Do not use a Key Converter for this mapping. |
Serialized Object Converter | |
Type Conversion Converter | |
Object Type Converter |
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
- Select the mapped attribute in the Navigator. Its properties appear in the Editor.
- Click the Converter tab. The Converter tab appears.
- Click the Value Converter tab. The Value Converter tab appears.
Converter Tab, Value Converter Subtab - Select the appropriate Value Converter.
Converter | Description |
---|---|
No Converter | Do not use a Value Converter for this mapping. |
Serialized Object Converter | |
Type Conversion Converter | |
Object Type Converter |