1 Reply Latest reply on May 15, 2006 8:26 AM by armita

    Enum field problem in entity

    armita

      I am trying to implement a enum property as described in Ricks weblog. The code works fine but it seems there is a hibernate problem or something.
      when it writes the field to the database, it stores the cardinal value of the Enum but while reading it wants to get the String value of it and therefor returns this error message:

      java.lang.IllegalArgumentException: Unknown name value for enum class com.tarhyar.user.Roles: 0
      16:41:02,441 ERROR [STDERR] at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:108)
      16:41:02,441 ERROR [STDERR] at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:104)
      16:41:02,442 ERROR [STDERR] at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
      16:41:02,442 ERROR [STDERR] at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1983)
      


      If I change the field to the Enums string value by hand in the database hibernate works OK.

        • 1. Re: Enum field problem in entity
          armita

          I changed the column type to int and it is working know. But it seems despite the doc which claims that Enum type is able to work with int and string column type. It is not capable of working with strings. Or maybe I am missing a configuration?