java.lang.ClassCastException: java.math.BigInteger

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I have code that basically does the following: session = factory.openSession() bean = session.find(<query string>)[0] connection = session.connection() stmt = connection.prepareCall(<a stored procedure>) stmt.execute() // The data stored in 'bean' is now changed in the database // by the stored procedure newSession = factory.openSession() At this pointI have tried: newBean = newSession.load(Bean.class, bean.getId()) and also: newBean = newSession.load("FROM B IN class Bean WHERE B.id = " + bean.getId())[0] The first code crashes with a ClassCastException, the second code works fine. The ClassCastException appears to be occurring setting the id property of the bean, which is declared as a Long in the Java code, and a NUMBER(16) in Oracle. Here is the stack trace: [java] java.lang.ClassCastException: java.math.BigInteger [java] at cirrus.hibernate.type.LongType.set(LongType.java:28) [java] at cirrus.hibernate.type.NullableType.nullSafeSet(NullableType.java:45) [java] at cirrus.hibernate.type.NullableType.nullSafeSet(NullableType.java:30) [java] at cirrus.hibernate.loader.Loader.prepareQueryStatement(Loader.java:427) [java] at cirrus.hibernate.loader.Loader.doFind(Loader.java:145) [java] at cirrus.hibernate.loader.Loader.loadEntity(Loader.java:506) [java] at cirrus.hibernate.loader.EntityLoader.load(EntityLoader.java:65) [java] at cirrus.hibernate.persister.EntityPersister.load(EntityPersister.java:427) [java] at cirrus.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1555) [java] at cirrus.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1426) [java] at cirrus.hibernate.impl.SessionImpl.load(SessionImpl.java:1364)
    via by Kevin Gilpin,
  • I have code that basically does the following: session = factory.openSession() bean = session.find(<query string>)[0] connection = session.connection() stmt = connection.prepareCall(<a stored procedure>) stmt.execute() // The data stored in 'bean' is now changed in the database // by the stored procedure newSession = factory.openSession() At this pointI have tried: newBean = newSession.load(Bean.class, bean.getId()) and also: newBean = newSession.load("FROM B IN class Bean WHERE B.id = " + bean.getId())[0] The first code crashes with a ClassCastException, the second code works fine. The ClassCastException appears to be occurring setting the id property of the bean, which is declared as a Long in the Java code, and a NUMBER(16) in Oracle. Here is the stack trace: [java] java.lang.ClassCastException: java.math.BigInteger [java] at cirrus.hibernate.type.LongType.set(LongType.java:28) [java] at cirrus.hibernate.type.NullableType.nullSafeSet(NullableType.java:45) [java] at cirrus.hibernate.type.NullableType.nullSafeSet(NullableType.java:30) [java] at cirrus.hibernate.loader.Loader.prepareQueryStatement(Loader.java:427) [java] at cirrus.hibernate.loader.Loader.doFind(Loader.java:145) [java] at cirrus.hibernate.loader.Loader.loadEntity(Loader.java:506) [java] at cirrus.hibernate.loader.EntityLoader.load(EntityLoader.java:65) [java] at cirrus.hibernate.persister.EntityPersister.load(EntityPersister.java:427) [java] at cirrus.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1555) [java] at cirrus.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1426) [java] at cirrus.hibernate.impl.SessionImpl.load(SessionImpl.java:1364)
    via by Kevin Gilpin,
    • java.lang.ClassCastException: java.math.BigInteger at cirrus.hibernate.type.LongType.set(LongType.java:28) at cirrus.hibernate.type.NullableType.nullSafeSet(NullableType.java:45) at cirrus.hibernate.type.NullableType.nullSafeSet(NullableType.java:30) at cirrus.hibernate.loader.Loader.prepareQueryStatement(Loader.java:427) at cirrus.hibernate.loader.Loader.doFind(Loader.java:145) at cirrus.hibernate.loader.Loader.loadEntity(Loader.java:506) at cirrus.hibernate.loader.EntityLoader.load(EntityLoader.java:65) at cirrus.hibernate.persister.EntityPersister.load(EntityPersister.java:427) at cirrus.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:1555) at cirrus.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1426) at cirrus.hibernate.impl.SessionImpl.load(SessionImpl.java:1364)
    No Bugmate found.