-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problem in mapping enum
PostPosted: Wed Sep 06, 2006 9:52 am 
Newbie

Joined: Wed Sep 06, 2006 9:15 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.