title: JPA: Parameterized instances of AttributeConverter
body: <p>We are developing an application connected to a legacy database. This is very "untyped", using strings for almost all data. What is worse is that is far of being homogeneous: it uses different patterns for dates or times ('YYDDMM', 'HHMMSS', milliseconds) and booleans ('Y'/'N', 'X'/' '), for example.</p>
  
  <p>We want to use JPA (EclipseLink) and custom converters. The problem is that <code>@Convert</code> expects a class implementing <code>AttributeConverter</code>, so we have to do new classes for each pattern. What I'd like is a BooleanConverter class, which can be instantiated with values 'Y'/'N' or 'X'/' '.</p>
  
  <p>This is obviously out of JPA spec, but maybe it's possible using EclipseLink annotations/configuration. Looking at its <a href="http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_convert.htm">@Convert</a> annotation, a converter can be specified by name. This sounds good to me if I can register a <code>ynBooleanConverter</code> and <code>xSpaceBooleanConverter</code>:</p>
  
  <pre><code>// Unfortunately, this method does not exist :(
  Session.addConverter('ynBooleanConverter', new BooleanConverter("Y", "N")); 
  
  @Entity
  public class MyEntity {
  
      @Convert("ynBooleanConverter")
      private Boolean myBoolean;
  
      ...
  }
  </code></pre>
  
  <p>Is it possible? What other options do we have?</p>