Skip Headers
Oracle® TopLink Developer's Guide
10g (10.1.3.1.0)
B28218-01
  Go To Documentation Library
Library
Go To Product List
Product
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
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 32-16 summarizes which mappings support this option.

Using TopLink Workbench

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

  1. Select the transformation mapping in the Navigator. Its properties appear in the Editor.

    Figure 32-15 Transformation Mapping, Attribute Transformer Field

    Description of Figure 32-15 follows
    Description of "Figure 32-15 Transformation Mapping, Attribute Transformer Field"

  2. Click Edit. The Specify Transformer dialog box appears.

    Figure 32-16 Specify Transformer Dialog Box

    Description of Figure 32-16 follows
    Description of "Figure 32-16 Specify Transformer Dialog Box"

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.