I'm not sure how to map a custom field in an enum to a DB column via Hibernate. I have an enum like this:
public enum SomeEnum {
ABC(1, "StringA"),
XYZ(5, "StringB");
private Integer code;
private String name;
private SomeEnum(Integer code, String name){
this.code=code;
this.name=name;
}
}
My hibernate file for the class with the enum has this:
<property name="seatType" column="entity_type_id" not-null="true">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">"my.path.name.SomeEnum"</param>
<param name="type">5</param>
</type>
</property>
I'd like to map the enum's 'code' field to the column (a smallint), but I'm not sure how to tell Hibernate to use the custom field instead of the default counting (0,1,2,3, etc) and Hibernate's documentation is fairly sparse.