Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-493

openjpa.jdbc.Schema property set causes wrong SQL queries when reading OPENJPA_SEQUENCE_TABLE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0, 1.0.1
    • 1.0.3, 1.2.0
    • jdbc
    • None
    • Windows XP, Java 5.0 IBM.

    Description

      When openjpa.jdbc.Schema is defined inserting object into the database causes exception because of wrong SQL query generation.

      In the sample openjpa.jdbc.Schema="KB", generates SQL: SELECT SEQUENCE_VALUE FROM KB.KB.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE WITH RR.

      This problem doesn't occur in version 0.9.7.

      Trace:
      <openjpa-1.0.1-r420667:592145 fatal store error> org.apache.openjpa.persistence.RollbackException: Attempt to update the sequence table "OPENJPA_SEQUENCE_TABLE" failed. The sequence table is typically created when you run the mappingtool's refresh action on any datastore identity class. If you have not run the mappingtool but want to create the sequence table, run:
      java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
      at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:419)
      at TestCase.testL1ProductEasier(TestCase.java:30)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:615)
      at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
      at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
      at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
      at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
      at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
      at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
      at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
      at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
      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-1.0.1-r420667:592145 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Attempt to update the sequence table "OPENJPA_SEQUENCE_TABLE" failed. The sequence table is typically created when you run the mappingtool's refresh action on any datastore identity class. If you have not run the mappingtool but want to create the sequence table, run:
      java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
      at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:3938)
      at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:97)
      at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:75)
      at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:371)
      at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.java:266)
      at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:60)
      at org.apache.openjpa.util.ImplHelper.generateValue(ImplHelper.java:160)
      at org.apache.openjpa.util.ImplHelper.generateFieldValue(ImplHelper.java:144)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignField(JDBCStoreManager.java:557)
      at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:450)
      at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:426)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:541)
      at org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:134)
      at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:501)
      at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2770)
      at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
      at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:940)
      at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1892)
      at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1852)
      at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1770)
      at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
      at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1292)
      at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:861)
      at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:408)
      ... 21 more
      Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Syntax error: Encountered "." at line 1, column 33.

      {SELECT SEQUENCE_VALUE FROM KB.KB.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE WITH RR}

      [code=20000, state=42X01]
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:201)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:57)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:228)
      at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:163)
      at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:140)
      at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:152)
      at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:475)
      at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:455)
      at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:444)
      at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.getSequence(TableJDBCSeq.java:467)
      at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.setSequence(TableJDBCSeq.java:511)
      at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:368)
      ... 41 more

      Attachments

        1. SchemaPropertyProblem.zip
          15 kB
          Przemek Koprowski

        Activity

          People

            techhusky Jeremy Bauer
            corp Przemek Koprowski
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: