EnumType.Ordinal vs EnumType.STRING

Posted on Posted in Hibernate

How to Map Enum to hibernate class:

public class UserGroup {

   private UserGroupStatusEnum userGroupStatus;

   public enum UserGroupStatusEnum{
      Active, Draft;

In the case above we have a table d_user_group, that will have a column user_group_status, that only accepts Enum as a parameter. If you specify EnumType.String it will store the actual words from your Enum:

Selecting EnumType.Ordinal in contrast will store Integer based on ordering, so Active will be 0, Draft will be 1, and so on.

Leave a Reply