Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Configuring a Type Conversion Converter

A type conversion converter is used to explicitly map a data source type to a Java type.

For more information about the type conversion converter, see "Type Conversion Converter".

Table 35-11 summarizes which mappings support this option.

Using TopLink Workbench

To create an type conversion direct mapping, use this procedure:

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.

  2. Click the Converter tab. The Converter tab appears.

  3. Select the Type Conversion Converter option.

    Figure 35-11 Converter Tab, Type Conversion Mapping

    Description of Figure 35-11  follows
    Description of "Figure 35-11 Converter Tab, Type Conversion Mapping"

Use the following information to complete the Type Conversion Converter fields on the Converter tab:

Field Description
Data Type Select the Java type of the data in the data source.
Attribute Type Select the Java type of the attribute in the Java class.

Using Java

You can set an oracle.toplink.converters.TypeConversionConverter on any instance of oracle.toplink.mappings.foundation.AbstractCompositeDirectCollectionMapping using AbstractCompositeDirectCollectionMapping method setValueConverter as Example 35-12 shows.

Example 35-12 Configuring a TypeConversionConverter in Java

// Create TypeConversionConverter instance
TypeConversionConverter typeConversionConverter = new TypeConversionConverter();
typeConversionConverter.setDataClass();
typeConversionConverter.setObjectClass();

// Set TypeConversionConverter on ArrayMapping
ArrayMapping arrayMapping = new ArrayMapping();
arrayMapping.setValueConverter(typeConversionConverter);
arrayMapping.setAttributeName("responsibilities");
arrayMapping.setStructureName("Responsibilities_t");
arrayMapping.setFieldName("RESPONSIBILITIES");
orDescriptor.addMapping(arrayMapping);

Configure the TypeConversionConverter instance using the following API:

  • setDataClass(java.lang.Class dataClass)–to specify the data type class

  • setObjectClass(java.lang.Class objectClass)–to specify the object type class