title: Mapping multiple values enum types with Hibernate Annotations
body: <p>In order to map Hibernate query result to a custom class containing an enum, I should do like this <a href="https://stackoverflow.com/questions/9633337/hibernate-sql-transformation-fails-for-enum-field-type/13616668">according to this post</a> but I don't want to use enum field name but one of its multiple values : </p>
  
  <pre><code>Properties params = new Properties();
  params.put("enumClass", "MyStatusEnum");
  params.put("useNamed", true)
  
  String sql = "SELECT "
      + "PRICE as price, "
      + "COMPANY as companyId, "
      + "NAME as name, "
      + "STATUS as statusEnum "
      + "FROM `FUC**** TABLE WITH SPACE`";
  
  List &lt;Item&gt; items = session.createNativeQuert(sql) // Obliged to use this method 
  // with deprecated transformer after because createQuery does not 
  // recognize ` escape character and if I use session.createQuery(sql, Item.class), 
  // Item is not recognized as an entity ...
      .addScalar(price) // Obliged to do it for all fields just because I need to do it for one field ?!
      .addScalar(companyId)
      .addScalar(name)
      .addScalar(statusEnum)
      .setResultTransformer(Transformers.aliasToBean(Item.class)).list();
  </code></pre>
  
  <p>1) The problem is for MyEnum.AVAILABLE for example, data will not be "available" but an int so this is my enum :</p>
  
  <pre><code>public enum MyEnum {
      AVAILABLE(0, 1),
      TO_SENT(1, null),
      ARCHIVED(2, null);
  
      private final int stateNum;
  
      private final Integer nextStateNum;
  
      MyEnum(int stateNum, Integer nextStateNum) {
          this.stateNum = stateNum;
          this.nextStateNum = nextStateNum;
      }
  }
  </code></pre>
  
  <p>And I want to map the STATUS (possible values : 0, 1, 2) in DB not to the name but to the first attribute code (stateNum), how to do that ? Coul I apply a function to get enum from code ?</p>
  
  <pre><code>Properties params = new Properties();
  params.put("enumClass", "Foo.ProfileStateEnum");
  params.put("???", "???");
  </code></pre>
  
  <p>2) How to get doc about properties mapping to enum and that for hibernate &lt; 5, we must use params.put("type", "12");, where is corresponding doc ?</p>
  
  <p>Thank you very much,</p>