Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents


Use @Transformation with a Transformation mapping to define the transformation of database columns into attribute values (unless the Transformation mapping is write-only, in which case it should have a @ReadTransformer annotation).

Annotation Elements

Table 2-71 describes this annotation's elements.

Table 2-71 @Transformation Annotation Elements

Annotation Element Description Default


(Optional) Defines whether the value of the field or property should be lazily loaded or must be eagerly fetched.

  • The EAGER strategy is a requirement on the persistence provider runtime that the value must be eagerly fetched.

  • The LAZY strategy is a hint to the persistence provider runtime.



(Optional) A hint as to whether the value of the field or property may be null. It is disregarded for primitive types, which are considered non-optional.



Unless it's a read-only mapping, either WriteTransformer annotation or WriteTransformers annotation should be specified. Each WriteTransformer defines transformation of the attribute value to a single database column value (column is specified in the WriteTransformer).


Example 2-114 shows how to use the @Transformation annotation.

Example 2-114 Using @Transformation Annotation

@Transformation(fetch=FecthType.LAZY, optional="true")
@AccessMethods(get="getNormalHours", set="setNormalHours")
   @Property(name="x", value="y")

Example 2-115 shows the same mapping, using the <transformation> XML element in the eclipselink-orm.xml file.

Example 2-115 Using <transformation> XML

<transformation name="normalHours" fetch="LAZY" optional="true">
     <read-transformer method="buildNormalHours"/>
     <write-transformer method="getStartTime">
             <column name="START_TIME"/>
     <write-transformer class="package.MyTimeTransformer">
             <column name="END_TIME"/>
     <access type="PROPERTY"/>
     <access-methods get="getNormalHours" set="setNormalHours"/>
        <property name="x" value="y"/>

See Also

For more information, see: