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 Field Transformer Associations

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

This section describes how to configure the field transformers that a transformation mapping uses to perform the object attribute-to-field transformation at write (marshal) 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-17 summarizes which mappings support this option.

Using TopLink Workbench

Use this procedure to complete the Object->Field Method fields:

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

    Figure 35-15 Transformation Mapping, Field Transformer Associations

    Description of Figure 35-15  follows
    Description of "Figure 35-15 Transformation Mapping, Field Transformer Associations"

  2. Click Add to add the necessary Field Transformer Associations for the mapping.

To add a new association, click Add. Continue with "Specifying Field-to-Transformer Associations".

To change an existing association, click Edit. Continue with "Specifying Field-to-Transformer Associations".

To delete an existing association, select the field transformation association and click Delete.

Specifying Field-to-Transformer Associations

To specify the actual transformation method or class used for the field of a transformation mapping, use this procedure.

  1. From the Transformation Mapping, Field Transformer Associations, click Add or Edit. The Specify Field-Transformer Association dialog box appears.

    Figure 35-16 Specify Field-Transformer Association Dialog Box

    Specify Field-Transformer Association
  2. Complete each field on the dialog box.

Field Description
Field Select the database field (from the descriptor's associated table) for this transformation.
Transformer Select one of the following methods to control the transformation:
    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 TopLink Workbench application classpath.

Using Java

You can specify a specific transformation method on your domain object or an instance of oracle.toplink.mappings.Transfomers.FieldTransformer (you can also extend the FieldTransformerAdapter). Using a FieldTransformer is non-intrusive: that is, your domain object does not need to implement a TopLink interface or provide a special transformation method.

You can configure a method-based field transformer using AbstractTransformationMapping method addFieldTransformation, passing in the name of the database field and the name of the domain object method to use.

You can configure a class-based field transformer using AbstractTransformationMapping method addFieldTransformer, passing in the name of the database field and an instance of oracle.toplink.mappings.Transfomers.FieldTransformer.

A convenient way to create a FieldTransformer is to extend FieldTransformerAdapter.