title: Mapping enum to string in hibernate
body: <p>I've got a Category Hibernate model:</p>
  
  <pre><code>@Entity
  @Table(name = "category")
  public class Category {
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      @Column(name = "id")
      private long id;
  
      @Column(name = "type")
      private String type;
  </code></pre>
  
  <p>which have a type string field. Also I've got a Java enum which represent a type of a category:</p>
  
  <pre><code>public enum CategoryType {
      INCOME, OUTCOME;
  }
  </code></pre>
  
  <p>which I would like to use instead of the string type. The SQL accepts two distinct values in the varchar parameter: either <code>CategoryIncome</code> or <code>CategoryOutcome</code>. I would like the Category model class to accept an enum variable - and map it somehow to the string whenever hibernate asks for it.</p>
  
  <p>Is it possible?</p>