Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring Attribute Transformer

A transformation mapping is made up of an attribute transformer for field-to-attribute transformation at read (unmarshall) time and one or more field transformers for attribute-to-field transformation at write (marshall) time (see "Configuring Field Transformer Associations").

This section describes how to configure the attribute transformer that a transformation mapping uses to perform the field-to-attribute transformation at read (unmarshal) time.

You can do this using either a method or class-based transformer.

A method-based transformer must map to a method in the domain object.

A class-based transformer allows you to place the transformation code in another class, making this approach non-intrusive: that is, your domain object does not need to implement a TopLink interface or provide a special transformation method

Table 35-16 summarizes which mappings support this option.

Table 35-16 Mapping Support for Attribute Transformer

Mapping | Using TopLink Workbench | Using Java
--- | --- | ---
Relational Mappings |  |
Transformation Mapping |  |
EIS Mappings |  |
EIS Transformation Mapping |  |
XML Mappings |  |
XML Transformation Mapping |  |

## Using TopLink Workbench

To specify a mapping's attribute transformer, use this procedure:

Click Edit. The Specify Transformer dialog box appears. Use the following information to enter data in each field of the dialog box and click OK:

Field | Description
--- | ---
Use Transformation Method | Select a specific method to control the transformation. A method based transformer must map to a method in the domain object.
Use Transformer Class | Select a specific class to control the transformation. The class must be available on the TopLink Workbench application classpath.

## Using Java

You can configure a method-based attribute transformer using `AbstractTransformationMapping` method `setAttributeTransformation`, passing in the name of the domain object method to use.

You can configure a class-based attribute transformer using `AbstractTransformationMapping` method `setAttributeTransformer`, passing in an instance of `oracle.toplink.mappings.Transfomers.AttributeTransformer`.

A convenient way to create an `AttributeTransformer` is to extend `AttributeTransformerAdapter`.