Enumeration mapping in hibernate hbm?

I have an enumeration as shown below.

public enum ExampleEnum { ONE(1), TWO(2); private int action; private ExampleEnum (int action){ this.action = action; } /** * @return the action */ public int getAction() { return action; } /** * @param action the action to set */ public void setAction(int action) { this.action = action; } } 

I need to save integer values, not ONE and TWO. How can i do this? I have below config in my hbm:

 <property name="action"> <column name="ACTION" /> <type name="org.hibernate.type.EnumType"> <param name="enumClass">com.ExampleEnum</param> </type> </property> 

Do I need to have any other configuration to store integers? Please help me!

Thanks!

+4
source share
1 answer

`

 <class name="package.class" table="database table name"> <id name="get/set parameter....your first attribute" type="int" column="data base columnname"> <generator class="increment"/><!--using auto increment--> </id> <property name="get/set parameter your second attribute"> <column name="data base column name"/> </property> </class>` 
0
source

All Articles