Mapping enums with Hibernate

First a mapping that uses the enum ordinal:
        <property name="type" column="user_type_code">
            <type name="org.hibernate.type.EnumType">
                <param name="enumClass">com.blogspot.pragmatastic.UserType</param>
            </type>
        </property>
and then a variation that uses the enum name:

        <property name="type" column="user_type_name">
            <type name="org.hibernate.type.EnumType">
                <param name="enumClass">com.blogspot.pragmatastic.UserType</param>
                <param name="type">12</param>
            </type>
        </property>

3 comments:

  1. 12 is equivalent to java.sql.Types.VARCHAR.

    ReplyDelete
  2. Half day of panicking and searching ended by your blog post. Thanks a ton mate !

    ReplyDelete