org.apache.openjpa.util.StoreException: Wrong data type: java.lang.NumberFormatException: For input string: "Red"

Apache's JIRA Issue Tracker | David Blevins | 8 years ago
  1. 0

    It seems that the order of parameters filled into the SQLBuffer are getting mixed. Seeing this with a bidirectional many-to-one where the owning side uses a compound primary key resulting in a compound foreign key. When the owning side's collection is loaded the sql is correctly generated with the foreign keys in the where clause but the values are not passed in the correct order. There is clearly great care taken in regards to order when the sql string SQLBuffer is getting filled in, but there seems to be a second pass where the parameter values are collected and the order in this case *appears* to be alphabetical. I.e. the two values in the compound key are "id" and "brandname", if "brandname" is renamed to "zbrandname" the test will consistently pass. Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error> org.apache.openjpa.util.StoreException: Wrong data type: java.lang.NumberFormatException: For input string: "Red" at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238) at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203) at org.apache.openjpa.jdbc.sql.HSQLDictionary.newStoreException(HSQLDictionary.java:292) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:632) at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116) at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78) at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2920) at org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2998) at org.apache.openjpa.kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2241) at org.apache.openjpa.kernel.StateManagerImpl.fetchField(StateManagerImpl.java:777) at org.apache.openjpa.kernel.StateManagerImpl.fetch(StateManagerImpl.java:739) at org.apache.openjpa.enhance.RedefinitionHelper$1.invoke(RedefinitionHelper.java:230) at $Proxy20.size(Unknown Source) at org.superbiz.customid.TestBean.tx2(TestBean.java:55) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158) at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141) at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:122) at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:211) at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169) at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217) at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:286) ... 25 more Caused by: java.sql.SQLException: Wrong data type: java.lang.NumberFormatException: For input string: "Red" at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source) at org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:132) at org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:132) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:309) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.setString(LoggingConnectionDecorator.java:990) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:309) at org.apache.openjpa.jdbc.sql.DBDictionary.setString(DBDictionary.java:1097) at org.apache.openjpa.jdbc.sql.DBDictionary.setUnknown(DBDictionary.java:1298) at org.apache.openjpa.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java:630) at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:529) at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:485) at org.apache.openjpa.jdbc.sql.SelectImpl.prepareStatement(SelectImpl.java:463) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:379) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:599) at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:819) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:626) ... 47 more Here's a snapshot of the SelectImp instance just after it is built: • this = {org.apache.openjpa.jdbc.sql.SelectImpl@8556}"SELECT t0.ID, t0.QUANTITY FROM LINEITEM t0 WHERE t0.FK_FOR_ID = ? AND t0.FK_FOR_BRANDNAME = ?" • mapping = {org.apache.openjpa.jdbc.meta.ClassMapping@8381}"org.superbiz.customid.Invoice" • toCols = {org.apache.openjpa.jdbc.schema.Column[2]@8382} • [0] = {org.apache.openjpa.jdbc.schema.DynamicSchemaFactory$DynamicColumn@8409}"BRANDNAME" • [1] = {org.apache.openjpa.jdbc.schema.DynamicSchemaFactory$DynamicColumn@8425}"ID" • fromCols = {org.apache.openjpa.jdbc.schema.Column[2]@8382} • [0] = {org.apache.openjpa.jdbc.schema.DynamicSchemaFactory$DynamicColumn@8409}"BRANDNAME" • [1] = {org.apache.openjpa.jdbc.schema.DynamicSchemaFactory$DynamicColumn@8425}"ID" • oid = {org.apache.openjpa.util.ObjectId@8383}"org.superbiz.customid.Invoice-org.superbiz.customid.InvoiceKey@c412bd2" • store = {org.apache.openjpa.jdbc.kernel.JDBCStoreManager@8373} • pj = null • buf = null • parmList = {java.util.ArrayList@8720} size = 0 • collectParmValueOnly = true • pks = {java.lang.Object[2]@8790} • [0] = {java.lang.String@8413}"Red" • [1] = {java.lang.Integer@8429}"1" • toCols.length = 2 Note the primary key values are in the incorrect order for the way the sql statement was built. Later when setParameters is called: • this = {org.apache.openjpa.jdbc.sql.SQLBuffer@7747} • ps = {org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement@7752}"prepstmnt 7374346 SELECT t0.ID, t0.QUANTITY FROM LINEITEM t0 WHERE t0.FK_FOR_ID = ? AND t0.FK_FOR_BRANDNAME = ?" • cacheParams = {java.util.ArrayList@7753} size = 2 • [0] = {java.lang.String@7648}"Red" • [1] = {java.lang.Integer@7652}"1" • _params = {java.util.ArrayList@7754} size = 2 • [0] = {java.lang.Integer@7652}"1" • [1] = {java.lang.String@7648}"Red" The interesting thing is that the value of _params is correct and matches the sql. For some reason there

    Apache's JIRA Issue Tracker | 8 years ago | David Blevins
    org.apache.openjpa.util.StoreException: Wrong data type: java.lang.NumberFormatException: For input string: "Red"
  2. 0

    [OpenJPA-dev] [jira] Created: (OPENJPA-872) Compound custom id in bidirectional many-to-one - Grokbase

    grokbase.com | 4 months ago
    org.apache.openjpa.util.StoreException: Wrong data type: java.lang.NumberFormatException: For input string: "Red"
  3. 0

    Hello! I have following problem: when using HQL query "select item.id, item.name from Item as item where item.class = ?" and trying to use clause Query.setParameter (0, SubItem.class) I am getting following exception from underlying database since hibernate doese not properly convert parameter into associated discriminator value: 2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000> 2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000> 2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item"> 2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item"> org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select abstractco0_.id as col_0_0_, abstractco0_.name as col_1_0_ from TABLE abstractco0_ where abstractco0_.type=?]; SQL state [37000]; error code [-16]; Wrong data type: For input string: "Item"; nested exception is java.sql.SQLException: Wrong data type: For input string: "Item java.sql.SQLException: Wrong data type: For input string: "Item" at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source) at org.hibernate.type.StringType.set(StringType.java:24) at org.hibernate.type.ClassType.set(ClassType.java:35) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:44) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1115) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1177) at org.hibernate.loader.Loader.doQuery(Loader.java:390) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74) Please also examine bug http://opensource.atlassian.com/projects/hibernate/browse/HHH-1749 it observes situation from discriminatort to class point of view. PS. There are several forum posts regarding almost same issues: http://forum.hibernate.org/viewtopic.php?t=956408&highlight=discriminator+hql http://forum.hibernate.org/viewtopic.php?t=941125&highlight=discriminator+class+name+hql PPS. If required I could provide sample mappings and code snippets.

    Hibernate JIRA | 1 decade ago | Ignat Zapolsky
    java.sql.SQLException: Wrong data type: For input string: "Item"
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hello! I have following problem: when using HQL query "select item.id, item.name from Item as item where item.class = ?" and trying to use clause Query.setParameter (0, SubItem.class) I am getting following exception from underlying database since hibernate doese not properly convert parameter into associated discriminator value: 2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000> 2006-06-14 15:04:30,828 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: -16, SQLState: 37000> 2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item"> 2006-06-14 15:04:30,843 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Wrong data type: For input string: "Item"> org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select abstractco0_.id as col_0_0_, abstractco0_.name as col_1_0_ from TABLE abstractco0_ where abstractco0_.type=?]; SQL state [37000]; error code [-16]; Wrong data type: For input string: "Item"; nested exception is java.sql.SQLException: Wrong data type: For input string: "Item java.sql.SQLException: Wrong data type: For input string: "Item" at org.hsqldb.jdbc.Util.throwError(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source) at org.hibernate.type.StringType.set(StringType.java:24) at org.hibernate.type.ClassType.set(ClassType.java:35) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62) at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:44) at org.hibernate.loader.Loader.bindPositionalParameters(Loader.java:1115) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1177) at org.hibernate.loader.Loader.doQuery(Loader.java:390) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74) Please also examine bug http://opensource.atlassian.com/projects/hibernate/browse/HHH-1749 it observes situation from discriminatort to class point of view. PS. There are several forum posts regarding almost same issues: http://forum.hibernate.org/viewtopic.php?t=956408&highlight=discriminator+hql http://forum.hibernate.org/viewtopic.php?t=941125&highlight=discriminator+class+name+hql PPS. If required I could provide sample mappings and code snippets.

    Hibernate JIRA | 1 decade ago | Ignat Zapolsky
    java.sql.SQLException: Wrong data type: For input string: "Item"
  6. 0

    saving a Blob in the CRUD admin.

    Google Groups | 6 years ago | dimitri
    org.hibernate.exception.DataException: could not insert: [models.Candidat] org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java: 1235)

    1 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.sql.SQLException

      Wrong data type: java.lang.NumberFormatException: For input string: "Red"

      at org.hsqldb.jdbc.Util.throwError()
    2. HSQLDB
      jdbcPreparedStatement.setString
      1. org.hsqldb.jdbc.Util.throwError(Unknown Source)
      2. org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source)
      3. org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source)
      3 frames
    3. Commons DBCP
      DelegatingPreparedStatement.setString
      1. org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:132)
      2. org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:132)
      2 frames
    4. OpenJPA Aggregate Jar
      RedefinitionHelper$1.invoke
      1. org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:309)
      2. org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.setString(LoggingConnectionDecorator.java:990)
      3. org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:309)
      4. org.apache.openjpa.jdbc.sql.DBDictionary.setString(DBDictionary.java:1097)
      5. org.apache.openjpa.jdbc.sql.DBDictionary.setUnknown(DBDictionary.java:1298)
      6. org.apache.openjpa.jdbc.sql.SQLBuffer.setParameters(SQLBuffer.java:630)
      7. org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:529)
      8. org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:485)
      9. org.apache.openjpa.jdbc.sql.SelectImpl.prepareStatement(SelectImpl.java:463)
      10. org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:379)
      11. org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339)
      12. org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420)
      13. org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230)
      14. org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220)
      15. org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:599)
      16. org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:819)
      17. org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:626)
      18. org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238)
      19. org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203)
      20. org.apache.openjpa.jdbc.sql.HSQLDictionary.newStoreException(HSQLDictionary.java:292)
      21. org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
      22. org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
      23. org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
      24. org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:632)
      25. org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
      26. org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
      27. org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2920)
      28. org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2998)
      29. org.apache.openjpa.kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2241)
      30. org.apache.openjpa.kernel.StateManagerImpl.fetchField(StateManagerImpl.java:777)
      31. org.apache.openjpa.kernel.StateManagerImpl.fetch(StateManagerImpl.java:739)
      32. org.apache.openjpa.enhance.RedefinitionHelper$1.invoke(RedefinitionHelper.java:230)
      32 frames
    5. Unknown
      $Proxy20.size
      1. $Proxy20.size(Unknown Source)
      1 frame
    6. org.superbiz.customid
      TestBean.tx2
      1. org.superbiz.customid.TestBean.tx2(TestBean.java:55)
      1 frame
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:585)
      4 frames
    8. OpenEJB :: OSGi :: Core
      BaseEjbProxyHandler.invoke
      1. org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:158)
      2. org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:141)
      3. org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:122)
      4. org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:211)
      5. org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
      6. org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217)
      7. org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77)
      8. org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:286)
      8 frames