title: Using enum property as ormlite column value instead of ordinal. is it possible?
body: <pre><code>@DatabaseField(dataType=DataType.ENUM_STRING,columnName=TIPO_FIELD_NAME)
  private TipoPedido tipo;
  
  public enum TipoPedido {
      REGISTARNOTIFICACAORESPOSTA("Registar Notificação Resposta",SIGLA_TIPO_REGISTARNOTIFICATIORESPOSTA);
  
      private String tipoName;
  
  
      private String tipoValue;
  
      TipoPedido(String tipoName,String tipoValue){
          this.tipoName=tipoName;
          this.tipoValue=tipoValue;
      }
  
      public String getTipoName(){
          return tipoName;
      }
  
      public String getTipoValue(){
          return tipoValue;
      }
  
  }
  </code></pre>
  
  <p>Is it possible to use the tipoValue enum property as the value for the column instead of the ordinal?</p>
  
  <p>Edit:here's what i did:</p>
  
  <p>Created the MyEnumPersister class:</p>
  
  <pre><code>public class MyEnumPersister extends EnumStringType{
  
  private static final MyEnumPersister singleTon = new MyEnumPersister();
  
  /**
   * @param sqlType
   * @param classes
   */
  protected MyEnumPersister() {
  
      super(SqlType.STRING, new Class&lt;?&gt;[] { Enum.class });
  }
  
  public static MyEnumPersister getSingleton() {
      return singleTon;
  }
  
  
  @Override
  public Object javaToSqlArg(FieldType fieldType, Object obj) {
  
      return ((EstadoPedido)obj).getEstadoValue();
  }
  
  
  @Override
  public Object sqlArgToJava(FieldType fieldType, Object sqlArg, int columnPos)
          throws SQLException {
  
      return PedidoDTO.siglaEstadoPedidoComparator((String)sqlArg);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>In javatoSqlArg i return directly the string corresponding to the estadoValue by using the getter inside the Enum.
  I assume to get it back to a Enum from the DataBase i will need to implement the sqlArgToJava method too, but i'm yet to build it.</p>
  
  <p>edit2: Seems that when i do a query on the table that holds the data, the method javaToSqlArg gets called before the sqlArgToJava, why??? here's the query:</p>
  
  <pre><code>public List&lt;PedidoDTO&gt; getPendingRequests(){
  
      List&lt;PedidoDTO&gt; pendingReq=null;
      QueryBuilder&lt;PedidoDTO, Integer&gt; queryBuild=null;
  
      try {
          queryBuild=getHelper().getPedidosDao().queryBuilder();
          pendingReq=queryBuild.where().eq(PedidoDTO.ESTADO_FIELD_NAME, PedidoDTO.SIGLA_ESTADO_PENDENTE).query();
      } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      return pendingReq;
  }
  </code></pre>
  
  <p>The obj value appears as "P" which was what i convert to sql when i inserted it in the Database. Doesnt make too much sense....</p>