4 Replies Latest reply on Sep 19, 2007 1:45 PM by Andrew Rubinger

    Problem with enum datatype

    Imran Pariyani Newbie

      hello

      I have a problem with the enum datatye. If i try to get an entity with enum as a field in it every thing works fine the problem occurs when i have a native query with only the enum field ..
      for example :

      String query = "SELECT DISTINCT type FROM card WHERE type IS NOT NULL ORDER BY type";
      return this.manager.createNativeQuery(query.toString()).getResultList();


      as output instead of the enum string i get only the first character .. here is the debug output of jboss

      2007-06-26 22:10:57,267 DEBUG [org.hibernate.SQL] SELECT DISTINCT type FROM card WHERE type IS NOT NULL ORDER BY type
      2007-06-26 22:10:57,316 TRACE [org.hibernate.type.CharacterType] returning 'M' as column: type
      2007-06-26 22:10:57,316 TRACE [org.hibernate.type.CharacterType] returning 'V' as column: type
      2007-06-26 22:10:57,317 TRACE [org.hibernate.type.CharacterType] returning 'E' as column: type
      2007-06-26 22:10:57,318 TRACE [org.hibernate.type.CharacterType] returning 'N' as column: type
      


      the question is why does it map the enum datatype of mysql to charactertype instead of string ..
      It sounds like a silly question but as i am new to ejb3 i had no other option but to ask :)

      Awaiting response ..

      thanks
      Imran