OpenJPA
  1. OpenJPA
  2. OPENJPA-1839

TestXMLCustomerOrder failed against Oracle with "ORA-01461: can bind a LONG value only for insert into a LONG column"

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0.0, 2.0.1
    • Fix Version/s: 2.0.2, 2.1.0
    • Component/s: jdbc
    • Labels:
      None

      Description

      A few junit tests failed with exception similar to the following stack.

      30500 test TRACE [main] openjpa.Runtime - An exception occurred while ending the transaction. This exception will be re-thrown.
      <openjpa-2.1.0-SNAPSHOT-r422266:1022129 fatal store error> org.apache.openjpa.util.StoreException: The transaction has been rolled back. See the nested exceptions for details on the errors that occurred.
      FailedObject: org.apache.openjpa.persistence.xmlmapping.entities.Order@16c616c6
      at org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2311)
      at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2149)
      at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2046)
      at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1964)
      at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
      at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1488)
      at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:925)
      at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:560)
      at org.apache.openjpa.persistence.xmlmapping.query.TestXMLCustomerOrder.setUp(TestXMLCustomerOrder.java:86)
      at junit.framework.TestCase.runBare(TestCase.java:125)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:562)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:538)
      at junit.framework.TestResult$1.protect(TestResult.java:106)
      at junit.framework.TestResult.runProtected(TestResult.java:124)
      at junit.framework.TestResult.run(TestResult.java:109)
      at junit.framework.TestCase.run(TestCase.java:118)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.run(AbstractPersistenceTestCase.java:206)
      at junit.framework.TestSuite.runTest(TestSuite.java:208)
      at junit.framework.TestSuite.run(TestSuite.java:203)
      at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      Caused by: <openjpa-2.1.0-SNAPSHOT-r422266:1022129 fatal store error> org.apache.openjpa.util.LockException: Unable to obtain an object lock on "org.apache.openjpa.persistence.xmlmapping.entities.Order@16c616c6".
      FailedObject: org.apache.openjpa.persistence.xmlmapping.entities.Order@16c616c6
      at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4851)
      at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4829)
      at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:137)
      at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:78)
      at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:217)
      at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:63)
      at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)
      at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:738)
      at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:131)
      ... 24 more
      Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01461: can bind a LONG value only for insert into a LONG column

      {prepstmnt 1578655256 INSERT INTO TORDERXML (oid, amount, delivered, shipAddress, version, CUSTOMER_COUNTRYCODE, CUSTOMER_ID) VALUES (?, ?, ?, XMLType(?), ?, ?, ?) [params=?, ?, ?, ?, ?, ?, ?]}

      [code=1461, state=72000]
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:274)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:262)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$5(LoggingConnectionDecorator.java:261)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeBatch(LoggingConnectionDecorator.java:1273)
      at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeBatch(DelegatingPreparedStatement.java:263)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeBatch(JDBCStoreManager.java:1790)
      at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.executeBatch(BatchingPreparedStatementManagerImpl.java:356)
      at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:187)
      ... 29 more

        Issue Links

          Activity

          Albert Lee created issue -
          Hide
          Albert Lee added a comment -

          OpenJPA

          "CREATE TABLE TORDERXML (oid NUMBER NOT NULL, amount NUMBER, delivered NUMBER, shipAddress XMLType, version NUMBER, CUSTOMER_COUNTRYCODE VARCHAR2(255), CUSTOMER_ID NUMBER, PRIMARY KEY (oid))"

          and

          "INSERT INTO TORDERXML (oid, amount, delivered, shipAddress, version, CUSTOMER_COUNTRYCODE, CUSTOMER_ID) VALUES (?, ?, ?, XMLType, ?, ?, ?) [params=(int) 10, (double) 850.0, (int) 0, (Reader) java.io.StringReader@61ea61ea, (int) 1, (String) USA, (int) 1]"

          After looking a little more, the ORA-01461 is very misleading. The cause of the problem is the XMLTYPE is set with setCharacterStream( 4, new StringReader( shippingAddrStr ), shippingAddrStr.length ) and if the length of shippingAddrStr is > 4000 characters, it will result with this exception.

          Show
          Albert Lee added a comment - OpenJPA "CREATE TABLE TORDERXML (oid NUMBER NOT NULL, amount NUMBER, delivered NUMBER, shipAddress XMLType, version NUMBER, CUSTOMER_COUNTRYCODE VARCHAR2(255), CUSTOMER_ID NUMBER, PRIMARY KEY (oid))" and "INSERT INTO TORDERXML (oid, amount, delivered, shipAddress, version, CUSTOMER_COUNTRYCODE, CUSTOMER_ID) VALUES (?, ?, ?, XMLType , ?, ?, ?) [params=(int) 10, (double) 850.0, (int) 0, (Reader) java.io.StringReader@61ea61ea, (int) 1, (String) USA, (int) 1] " After looking a little more, the ORA-01461 is very misleading. The cause of the problem is the XMLTYPE is set with setCharacterStream( 4, new StringReader( shippingAddrStr ), shippingAddrStr.length ) and if the length of shippingAddrStr is > 4000 characters, it will result with this exception.
          Show
          Albert Lee added a comment - Oracle documentation on the solution: http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/HowToLoadLargeXML.html#JDBCCode
          Hide
          Albert Lee added a comment -

          This problem is fixed in the 11g2 jdbc driver

          Show
          Albert Lee added a comment - This problem is fixed in the 11g2 jdbc driver
          Hide
          Albert Lee added a comment -

          This problem will be resolved under OPENJPA-1837.

          Show
          Albert Lee added a comment - This problem will be resolved under OPENJPA-1837 .
          Albert Lee made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.0.2 [ 12315257 ]
          Fix Version/s 2.1.0 [ 12314542 ]
          Resolution Duplicate [ 3 ]
          Albert Lee made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Milosz Tylenda made changes -
          Link This issue duplicates OPENJPA-1691 [ OPENJPA-1691 ]

            People

            • Assignee:
              Albert Lee
              Reporter:
              Albert Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development