title: Map postgreSQL enum to Java enum with JPA (EclipseLink) and custom converter
body: <p>I'm trying to map with JPA (<code>EclipseLink</code> provider) a postgreSQL <code>ENUM</code> type to Java enum type (and vice versa).</p>
  
  <p>I know I can easily map a Java enum to a <code>varchar</code> type in my postgreSQL database with the <code>@Enumerated</code> annotation but I want to map it in a postgreSQL<code>ENUM</code> tpye. I think I must use a custom EclipseLink converter to do this.</p>
  
  <p>So, I started to implement a <code>org.eclipse.persistence.mappings.converters.Converter</code> but I don't kown how to implement the <code>convertObjectValueToDataValue</code>, the <code>initialize</code> and the <code>isMutable</code> methods...</p>
  
  <p>Can someone explain me how to implement these methods please ?</p>
  
  <p>For now, my class is this one :</p>
  
  <pre><code>public class EnumConverter implements Converter {
  
  private static final long serialVersionUID = 1L;
  
  public Object convertDataValueToObjectValue(Object object, Session session) {
  
      if(object instanceof PGobject){
          return LangageEnum.valueOf(LangageEnum.class, ((PGobject)object).getValue());           
      }
  
      return null;
  }
  
  public Object convertObjectValueToDataValue(Object object, Session session) {
      // WHAT HERE...?
      // I tried to play with PGObject witout success...
      return object;
  }
  
  public void initialize(DatabaseMapping arg0, Session arg1) {
      // WHAT INITIALIZATION HERE...?
  }
  
  public boolean isMutable() {
      // TRUE OR FALSE AND WHY...?
      return false;
  }
  
  }
  
  @Converter(name="langageConverter", converterClass=EnumConverter.class)
  @Convert(value="langageConverter")
  private LangageEnum langage;
  </code></pre>
  
  <p>Thanks for explanations, I searched for custom converters for EclipseLink with Google but this time Google was not my friend.</p>