Hi,
I am using Hibernate 3.2 and ran into a problem with enum class mapping:
Assume class Person has a field gender which is a type of GENDER enum class with only two instances GENDER.MALE and GENDER.FEMALE. It also has find method as GENDER.find(String str) where str can be "m" or "f".
Further assume there is a gender table having id and value columns, and only two rows in the table: (1, 'm') and (2,'f').
Now how should I create the mapping file to get the GENDER enum class created by the find method?
<class name="Person" table="PERSON">
<id name="id" type="long">
<generator class="sequence">
<param name="sequence">ID_SEQ</param>
</generator>
</id>
<many-to-one name="gender" class="GENDER" update="false" insert="false" fetch="select">
<!-- HOW TO DO MAPPING HERE? -->
<column name="gender_id" not-null="true" />
</many-to-one>
</class>
Your help is greatly appreciated!
-Herbert
|