Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Default Conversions and Converters/Convert"

Line 6: Line 6:
*[http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/annotations/Convert.html @Convert]
*[http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/mappings/converters/SerializedObjectConverter.html SerializedObjectConverter]
*[http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/mappings/converters/SerializedObjectConverter.html SerializedObjectConverter]

Revision as of 15:20, 2 May 2011

EclipseLink JPA

@Convert Annotation

The @Convert annotation specifies that a named converter should be used with the corresponding mapped attribute.

 @Target({METHOD, FIELD})
 public @interface Convert {
    String value() default "none";

The @Convert has the following reserved names:

  • serialized – places the org.eclipse.persistence.mappings.converters.SerializedObjectConverter on the associated mapping.
  • none – does not place a converter on the associated mapping.
@Convert Annotation Attributes
Attribute Description Default Required?
value The String name for your converter. "none" String No

The following example shows how to use the @Convert annotation to define the Employee field gender.

Example: @Convert Annotation
 public class Employee implements Serializable{
     public String getGender() {
         return gender;

Version: 2.2.0 DRAFT
Other versions...