java - Mapping an enum in hibernate hbm? -
i have enum below.
public enum exampleenum { one(1), two(2); private int action; private exampleenum (int action){ this.action = action; } /** * @return action */ public int getaction() { return action; } /** * @param action action set */ public void setaction(int action) { this.action = action; } }
i need save integer values not 1 , two. how can that? have below config in hbm:
<property name="action"> <column name="action" /> <type name="org.hibernate.type.enumtype"> <param name="enumclass">com.exampleenum</param> </type> </property>
do need have other configuration save integers? please me!
thanks!
`
<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 second attribute"> <column name="data base column name"/> </property> </class>`
Comments
Post a Comment