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


Use the @Converter annotation to specify a custom converter for modification of the data value(s) during the reading and writing of a mapped attribute.

Annotation Elements

Table 2-15 describes this annotation's elements.

Table 2-15 @Converter Annotation Elements

Annotation Element Description Default


The String name for your converter, must be unique across the persistence unit



The class of your converter. This class must implement the org.eclipse.persistence.mappings.converters.Converter interface.



Use @Converter to define a named converter that can be used with mappings. A converter can be defined on an entity class, method, or field. Specify a converter with the @Convert annotation on a Basic or ElementCollection mapping.

Using non-JPA Converter Annotations

EclipseLink provides a set of non-JPA converter annotations (in addition to the JPA default type mappings):

The persistence provider searches the converter annotations in the following order:

  1. @Convert

  2. @Enumerated

  3. @Lob

  4. @Temporal

  5. Serialized (automatic)

Specify the converters on the following classes:

Use the converters with the following mappings:

An exception is thrown if a converter is specified with any other type of mapping annotation.


Example 2-32 shows how to use the @Converter annotation to specify a converter class for the gender field.

Example 2-32 Using the @Converter Annotation

 public class Employee implements Serializable{
     @Converter (
     public String getGender() {
         return gender;

Example 2-33 shows how to use the <converter> element in the eclipselink-orm.xml file.

Example 2-33 Using <converter> XML

<entity class="Employee">
      <basic name="gender">
        <converter name="genderConverter" class="org.myorg.converters.GenderConverter"/>

See Also

For more information, see: