title: Why user defined @javax.persistence.Converter isn't recognized by hibernate when mapping the entity field to database column
body: <p>I have the following Entity containing a field of Enum type:</p>
  
  <pre><code>@Entity
  @Table(name = "INPUT_DATA")
  public class InputDataEntity implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @SequenceGenerator(name = "INPUT_DATA_SEQ", allocationSize = 1, sequenceName = "INPUT_DATA_SEQ")
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "INPUT_DATA_SEQ")
      private Long id;
  
      @Column(name = "FIELD1", nullable = false)
      private String field1;
  
      @Column(name = "FIELD2", nullable = false)
      @Convert(converter = Type.Converter.class)
      private Type field2;
  
      // getters and setters
  }
  </code></pre>
  
  <p>The Enum type looks like:</p>
  
  <pre><code>public enum Type {
  
      ENUM_ITEM_1("item1"),
      // more items
      ENUM_ITEM_N("itemN");
  
      private String code;
  
      private Type(String code) {
          this.code = code;
      }
  
      public static Type fromString(String name) {
          switch (name) {
              case "item1":
                  return ENUM_ITEM_1;
              // more cases
              case "itemN":
                  return ENUM_ITEM_N;
              default:
                  throw new IllegalArgumentException("Wrong value for Type");
          }
      }
  
      @Override
      public String toString() {
          return code;
      }
  
      @javax.persistence.Converter
      public static class Converter implements AttributeConverter&lt;Type, String&gt; {
         @Override
          public String convertToDatabaseColumn(Type attribute) {
              return attribute.toString();
          }
  
          @Override
          public Type convertToEntityAttribute(String s) {
              return Type.fromString(s);
          }
      }
  }
  </code></pre>
  
  <p>The problem is that hibernate doesn't recognize my <strong><em>Converter</em></strong> when I want to fetch data from the database.</p>
  
  <p>I've also tried:</p>
  
  <ul>
  <li>@Embedded and @Embeddable but with no luck.</li>
  <li>@Enumerated(EnumType.STRING) but again with no luck.</li>
  </ul>
  
  <p><strong>My question is:</strong>
  how to make hibernate to recognize my converter when converting the appropriate field?</p>
  
  <p>Many thanks in advance.</p>