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

    Enum field problem in entity

    blalls asdsd Novice

      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.