Till now I used Enums in domain objects with no problem,
Just add the Hibernate annotation:
@Enumerated(EnumType.STRING)
And the domain field saved to the db as selected by the EnumType
Now I am working on different application and trying to use enum in one of my domain object fields
For example:
My domain class is :
Code:
public class Note{
private String noteName;
private NoteType type;
}
Public enum NoteType{ text_note,image_note,reminder_note};
The application uses “hbm” files and I am trying to set the hbm to work with the Enum field (NoteType) so I configured set the hbm like:
Code:
<class name="com.comp.domain.Note" table="app_note" lazy="false">
<property name="type” column="note_type" >
<type name="EnumUserType">
<param name="enumClassName">com.comp.enums.NoteType</param> </type>
</property>
But it wont work, the application keep throwing these exceptions:
“Arithmetic overflow error converting varbinary to data type numeric”
After half day goggling on this matter I found another suggestion :
http://forum.hibernate.org/viewtopic.php?p=2377095Code:
<property name="myfield" length="30">
<type name="org.hibernate.type.EnumType">
<param name="enumClass">org.judge.myenum</param>
<param name="type">12</param>
</type>
</property>
this code throws this Exception:
MappingException: "Could not determine type for": org.hibernate.type.EnumType
I published the question in other ORM forum but didn't get an answer..
Hope you guys can help
Sharon