Skip Headers

# Using Java

Previous

Next

You can set an `oracle.toplink.converters.ObjectTypeConverter` on any instance of `oracle.toplink.mappings.foundation.AbstractCompositeDirectCollectionMapping` using `AbstractCompositeDirectCollectionMapping` method `setValueConverter` as Example: Configuring an ObjectTypeConverter in Java shows.

Configuring an ObjectTypeConverter in Java

    // Create ObjectTypeConverter instance
    ObjectTypeConverter objectTypeConvter = new ObjectTypeConverter();
    objectTypeConverter.addConversionValue("F", "Female");

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

Configure the `ObjectTypeConverter` instance using the following API:

- `addConversionValue(java.lang.Object fieldValue, java.lang.Object attributeValue)`–to associate data-type values to object-type values

- `addToAttributeOnlyConversionValue(java.lang.Object fieldValue, java.lang.Object attributeValue)`–to add one-way conversion values

- `setDefaultAttributeValue(java.lang.Object defaultAttributeValue)`–to set the default value