java.lang.IllegalArgumentException: Unknown ordinal value for enum class LevelEnum: 257

Hibernate JIRA | hiberdude | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Hibernate Community • View topic - Unknown ordinal value for enum class

    hibernate.org | 1 year ago
    java.lang.IllegalArgumentException: Unknown ordinal value for enum class LevelEnum: 257
  2. 0

    [ANN-235] Unknown ordinal value for enum class with Regular SQL - Hibernate JIRA

    atlassian.net | 1 year ago
    java.lang.IllegalArgumentException: Unknown ordinal value for enum class LevelEnum: 257
  3. 0

    Using Regular SQL, the retrieval of a bean with an enum type does not seem to work. ======= SQL Below Does not Work ======= SQLQuery q = hSession.createSQLQuery("select {tb.*} from TestBean tb where name=:name"); q.setString("name",aName); q.addEntity("tb",TestBean.class); return((TestBean)q.uniqueResult()); ======== HQL Below Works ======== Query q = hSession.createQuery("from TestBean tb where name=:name"); q.setString("name",aName); return((TestBean )q.uniqueResult()); ======== Enum Class ======== public enum LevelEnum { AN, RE; } ======== TestBean Class ======== import javax.persistence.*; public class TestBean public LevelEnum getLevel() { return level; } public void setLevel(LevelEnum level) { this.level = level; } private LevelEnum level; ======== java.lang.IllegalArgumentException: Unknown ordinal value for enum class LevelEnum: 257 at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:92) at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:104) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1899) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300) at org.hibernate.loader.Loader.getRow(Loader.java:1197) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569) at org.hibernate.loader.Loader.doQuery(Loader.java:689) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2150) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:117) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1672) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:147) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:169)

    Hibernate JIRA | 1 decade ago | hiberdude
    java.lang.IllegalArgumentException: Unknown ordinal value for enum class LevelEnum: 257
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Using Regular SQL, the retrieval of a bean with an enum type does not seem to work. ======= SQL Below Does not Work ======= SQLQuery q = hSession.createSQLQuery("select {tb.*} from TestBean tb where name=:name"); q.setString("name",aName); q.addEntity("tb",TestBean.class); return((TestBean)q.uniqueResult()); ======== HQL Below Works ======== Query q = hSession.createQuery("from TestBean tb where name=:name"); q.setString("name",aName); return((TestBean )q.uniqueResult()); ======== Enum Class ======== public enum LevelEnum { AN, RE; } ======== TestBean Class ======== import javax.persistence.*; public class TestBean public LevelEnum getLevel() { return level; } public void setLevel(LevelEnum level) { this.level = level; } private LevelEnum level; ======== java.lang.IllegalArgumentException: Unknown ordinal value for enum class LevelEnum: 257 at org.hibernate.type.EnumType.nullSafeGet(EnumType.java:92) at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:104) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1899) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300) at org.hibernate.loader.Loader.getRow(Loader.java:1197) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569) at org.hibernate.loader.Loader.doQuery(Loader.java:689) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.doList(Loader.java:2150) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) at org.hibernate.loader.Loader.list(Loader.java:2024) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:117) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1672) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:147) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:169)

    Hibernate JIRA | 1 decade ago | hiberdude
    java.lang.IllegalArgumentException: Unknown ordinal value for enum class LevelEnum: 257

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Unknown ordinal value for enum class LevelEnum: 257

      at org.hibernate.type.EnumType.nullSafeGet()
    2. Hibernate
      CustomLoader.list
      1. org.hibernate.type.EnumType.nullSafeGet(EnumType.java:92)
      2. org.hibernate.type.CustomType.nullSafeGet(CustomType.java:104)
      3. org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
      4. org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:1899)
      5. org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1372)
      6. org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1300)
      7. org.hibernate.loader.Loader.getRow(Loader.java:1197)
      8. org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569)
      9. org.hibernate.loader.Loader.doQuery(Loader.java:689)
      10. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
      11. org.hibernate.loader.Loader.doList(Loader.java:2150)
      12. org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
      13. org.hibernate.loader.Loader.list(Loader.java:2024)
      14. org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:117)
      14 frames
    3. Hibernate
      SQLQueryImpl.list
      1. org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1672)
      2. org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:147)
      3. org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:169)
      3 frames