我试图在HBM文件中创建一个包含Enum作为字段的类.
HBM与此类似:
<class name="a.b.c.myObject" table="OBJECT" >
       <property name="myEnum" column="EXAMPLE" type="a.b.c.myEnum" />
</class>
让我们说这是Enum:
public enum myEnum{
    a, b, c;
}
问题是在DB中我期望看到该枚举的字符串值(a,b或c),但我获得了该字段的原始数据.
我怎么解决这个问题?
我是Java编程的新手.我的课程中有一个枚举数据类型:
public class Persons {
    private String name;
    private String family;
    private Date birthDate;
    public enum degree {Bsd, Msd, prof};
    private degree degree;
    ...
}
在我的MySQL数据库中,我有一个度为的字段为:ENUM('Bsd','Mds','prof')我的hibernate映射是这样的:
<class name="Entity.Professor" table="tbl_professor">
     <id column="ProfessorId" name="ProfessorId"/>
     <property column="name" name="name"/>
     <property column="family" name="family"/>
     <property column="birthDate" name="birthDate"/>
     <property column="degree" name="degree"/>
</class>
当我想在我的表中插入新记录时,我收到此错误:
Hibernate: insert into tbl_professor (name, family, birthDate, degree, ProfessorId) values (?, ?, ?, ?, ?)
Apr 26, 2013 6:15:24 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 1265, SQLState: 01000
Apr 26, 2013 6:15:24 …