I am trying to create a class in HBM file which contains an Enum as a field.
The HBM is similar to this:
<class name="a.b.c.myObject" table="OBJECT" >
<property name="myEnum" column="EXAMPLE" type="a.b.c.myEnum" />
</class>
and let's say that this is the Enum:
public enum myEnum{
a, b, c;
}
The problem is that in the DB I expected to see the String value of that enum (a,b or c) but instead I got the raw data of that field.
How can I solve that?
Here is the solution with Hibernate 3.6.x :
<class name="a.b.c.myObject" table="OBJECT">
<property name="myEnum" column="EXAMPLE">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">a.b.c.myEnum</param>
</type>
</property>
</class>