I am trying to create a class in HBM file which contains an Enum as a field.
The HBM is similar to this:
1) Easy solution: use Hibernate Annotations instead of XML-based mappings. Enum support is built-in:
@Entity
public class MyObject {
@Enumerated(EnumType.STRING)
@Column(name="EXAMPLE")
private MyEnum myEnum;
}
2) If you can't use annotations, you can still use the EnumType they provide in XML-based mappings. You do need to have appropriate hibernate-annotations.jar in your classpath during deployment but there's no compile-time dependency: