Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
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.
Use this procedure to complete the Object->Field Method fields:
Select the mapped attribute in the Navigator. Its properties appear in the Editor.
Figure 35-15 Transformation Mapping, Field Transformer Associations
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.
To specify the actual transformation method or class used for the field of a transformation mapping, use this procedure.
From the Transformation Mapping, Field Transformer Associations, click Add or Edit. The Specify Field-Transformer Association dialog box appears.
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. |
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
.