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

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.

  • 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
    via by David Blevins,
  • 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.
    via by Ignat Zapolsky,
  • saving a Blob in the CRUD admin.
    via by dimitri,
  • I don't know if this is restricted to just the embedded DB or not, but for some reason there's conversion errors showing up from MSN contacts when stored in the db. 2007.11.03 15:48:50 org.jivesoftware.openfire.gateway.util.Log4JToOpenfireAppender.append(Log4JToOpenfireAppender.java:49) Avatar: SQL exception while inserting avatar: java.sql.SQLException: Type Conversion not supported at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source) at org.jivesoftware.openfire.gateway.avatars.Avatar.insertIntoDb(Avatar.java:226) at org.jivesoftware.openfire.gateway.avatars.Avatar.<init>(Avatar.java:109) at org.jivesoftware.openfire.gateway.protocols.oscar.BasicFlapConnection$1.handleResponse(BasicFlapConnection.java:209) at net.kano.joscar.snac.SnacRequest.gotResponse(SnacRequest.java:344) at net.kano.joscar.snac.ClientSnacProcessor.continueHandling(ClientSnacProcessor.java:727) at net.kano.joscar.snac.AbstractSnacProcessor.processPacket(AbstractSnacProcessor.java:447) at net.kano.joscar.snac.AbstractSnacProcessor.access$100(AbstractSnacProcessor.java:134) at net.kano.joscar.snac.AbstractSnacProcessor$1.handlePacket(AbstractSnacProcessor.java:208) at net.kano.joscar.flap.AbstractFlapProcessor.processPacketSynchronously(AbstractFlapProcessor.java:231) at net.kano.joscar.flap.AsynchronousFlapProcessor$BackgroundPacketProcessor.tryProcessingPackets(AsynchronousFlapProcessor.java:75) at net.kano.joscar.flap.AsynchronousFlapProcessor$BackgroundPacketProcessor.run(AsynchronousFlapProcessor.java:63) at java.lang.Thread.run(Thread.java:595)
    via by Daniel Henninger,
  • I don't know if this is restricted to just the embedded DB or not, but for some reason there's conversion errors showing up from MSN contacts when stored in the db. 2007.11.03 15:48:50 org.jivesoftware.openfire.gateway.util.Log4JToOpenfireAppender.append(Log4JToOpenfireAppender.java:49) Avatar: SQL exception while inserting avatar: java.sql.SQLException: Type Conversion not supported at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source) at org.jivesoftware.openfire.gateway.avatars.Avatar.insertIntoDb(Avatar.java:226) at org.jivesoftware.openfire.gateway.avatars.Avatar.<init>(Avatar.java:109) at org.jivesoftware.openfire.gateway.protocols.oscar.BasicFlapConnection$1.handleResponse(BasicFlapConnection.java:209) at net.kano.joscar.snac.SnacRequest.gotResponse(SnacRequest.java:344) at net.kano.joscar.snac.ClientSnacProcessor.continueHandling(ClientSnacProcessor.java:727) at net.kano.joscar.snac.AbstractSnacProcessor.processPacket(AbstractSnacProcessor.java:447) at net.kano.joscar.snac.AbstractSnacProcessor.access$100(AbstractSnacProcessor.java:134) at net.kano.joscar.snac.AbstractSnacProcessor$1.handlePacket(AbstractSnacProcessor.java:208) at net.kano.joscar.flap.AbstractFlapProcessor.processPacketSynchronously(AbstractFlapProcessor.java:231) at net.kano.joscar.flap.AsynchronousFlapProcessor$BackgroundPacketProcessor.tryProcessingPackets(AsynchronousFlapProcessor.java:75) at net.kano.joscar.flap.AsynchronousFlapProcessor$BackgroundPacketProcessor.run(AsynchronousFlapProcessor.java:63) at java.lang.Thread.run(Thread.java:595)
    via by Daniel Henninger,
  • I don't know if this is restricted to just the embedded DB or not, but for some reason there's conversion errors showing up from MSN contacts when stored in the db. 2007.11.03 15:48:50 org.jivesoftware.openfire.gateway.util.Log4JToOpenfireAppender.append(Log4JToOpenfireAppender.java:49) Avatar: SQL exception while inserting avatar: java.sql.SQLException: Type Conversion not supported at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setParameter(Unknown Source) at org.hsqldb.jdbc.jdbcPreparedStatement.setString(Unknown Source) at org.jivesoftware.openfire.gateway.avatars.Avatar.insertIntoDb(Avatar.java:226) at org.jivesoftware.openfire.gateway.avatars.Avatar.<init>(Avatar.java:109) at org.jivesoftware.openfire.gateway.protocols.oscar.BasicFlapConnection$1.handleResponse(BasicFlapConnection.java:209) at net.kano.joscar.snac.SnacRequest.gotResponse(SnacRequest.java:344) at net.kano.joscar.snac.ClientSnacProcessor.continueHandling(ClientSnacProcessor.java:727) at net.kano.joscar.snac.AbstractSnacProcessor.processPacket(AbstractSnacProcessor.java:447) at net.kano.joscar.snac.AbstractSnacProcessor.access$100(AbstractSnacProcessor.java:134) at net.kano.joscar.snac.AbstractSnacProcessor$1.handlePacket(AbstractSnacProcessor.java:208) at net.kano.joscar.flap.AbstractFlapProcessor.processPacketSynchronously(AbstractFlapProcessor.java:231) at net.kano.joscar.flap.AsynchronousFlapProcessor$BackgroundPacketProcessor.tryProcessingPackets(AsynchronousFlapProcessor.java:75) at net.kano.joscar.flap.AsynchronousFlapProcessor$BackgroundPacketProcessor.run(AsynchronousFlapProcessor.java:63) at java.lang.Thread.run(Thread.java:595)
    via by Daniel Henninger,
  • Problems with setString
    via hsqldb by katherina
    ,
    • 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) 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) ... 29 more

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    3 more bugmates