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 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 32-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 32-17 Transformation Mapping, Field Transformer Associations

    Description of Figure 32-17 follows
    Description of "Figure 32-17 Transformation Mapping, Field Transformer Associations"

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 32-18 Specify Field-Transformer Association Dialog Box

    Description of Figure 32-18 follows
    Description of "Figure 32-18 Specify Field-Transformer Association Dialog Box"

Use the following information to 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.