Hi,
I followed the wiki (
http://www.hibernate.org/265.html) in order to use enum object in my POJO. When I'm generating POJO classes, I get the MyEnumUserType instead of MyEnum in my getters and setters
I'm using hibernate 3.1.3 and Hibernate tools 3.2.0beta7
I'm using an ant script to generate POJO
Here is the target I'm using :
Code:
<target name="hbm2java"
depends="depends"
description="Generation des POJOs java">
<echo>Generating java code</echo>
<hibernatetool destdir="${basedir}/src/main/java">
<configuration propertyfile="${config.dir}/hibernate.properties">
<fileset dir="${resources.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</configuration>
<hbm2java jdk5="true" />
</hibernatetool>
<echo>Done</echo>
</target>
Sample of my mapping code :
Code:
<hibernate-mapping package="my.project.domain">
<class name="ElementSchemaExamen" table="ELEMENT_SCHEMA_EXAMEN" schema="My_DB">
<id name="idElementSchemaExamen" type="java.lang.Long">
<meta attribute="scope-set">protected</meta>
<column name="ID_ELEMENT_SCHEMA_EXAMEN"></column>
<generator class="identity"></generator>
</id>
<property name="type" type="my.project.enums.EnumTypeElementSchemaExamenUserType" >
<column name="TYPE_ELEMENT_SCHEMA_EXAMEN" length="15" not-null="true" />
</property>
</class>
</hibernate-mapping>
where EnumTypeElementSchemaExamenUserType is the following class
Code:
public class EnumTypeElementSchemaExamenUserType extends EnumUserType<EnumTypeElementSchemaExamen> {
public EnumTypeElementSchemaExamenUserType() {
super(EnumTypeElementSchemaExamen.class);
}
}
and the EnumTypeElementSchemaExamen class
Code:
public enum EnumTypeElementSchemaExamen {
RETRACTATION,
INFLAMMATION,
LESION;
}
I'm getting the following code where it's the EnumTypeElementSchemaExamenUserType class that has been put instead of EnumTypeElementSchemaExamen
Code:
public class ElementSchemaExamen implements java.io.Serializable {
// Fields
private Long idElementSchemaExamen;
private EnumTypeElementSchemaExamenUserType type;
......
// Property accessors
public Long getIdElementSchemaExamen() {
return this.idElementSchemaExamen;
}
protected void setIdElementSchemaExamen(Long idElementSchemaExamen) {
this.idElementSchemaExamen = idElementSchemaExamen;
}
public EnumTypeElementSchemaExamenUserType getType() {
return this.type;
}
public void setType(EnumTypeElementSchemaExamenUserType type) {
this.type = type;
}
}
any help will be great.
Thanks