title: Hibernate Enumeration Mapping
body: <p>I have a legacy database table that, for simplicity sake looks like:</p>
  
  <pre><code>  table address{
      varchar line1
      varchar line2
      varchar line3
      varchar(1) deliveryline
    }
  </code></pre>
  
  <p>There is a check constraint on <code>deliveryline</code> guaranteeing it has the values <code>'1,'2', or '3'</code>.</p>
  
  <p>This seems like a good candidate for enumeration in hibernate.  I have an entity that looks like this representing the Address table:</p>
  
  <pre><code>  public class Address{
      String line1;
      String line2;
      String line3;
      DeliveryLine deliveryLine;
    }
  </code></pre>
  
  <p>I normally use <code>@Enumerated(EnumType.STRING)</code> on when mapping enums, but that strategy does not work here.  For example:</p>
  
  <p>public enum DeliveryLine {
   1,2,3
  }
    This does not compile since the valid values in the database (1,2,3) are not valid Java Identifiers.</p>
  
  <p>Is there a straightforward way to coerce this mapping in hibernate?</p>