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

MappingTool attempts to create table in Oracle even when the table already exist

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.0.0-M3, 2.0.0
    • 2.0.0-beta3
    • tooling
    • None

    Description

      When SynchronizedMapping property is used, MappingTool attempts to create table in Oracle even when the table already exist. When it happens, the following exception is thrown.

      2203 test TRACE [main] openjpa.jdbc.SQL - <t 1183336072, conn 1912762882> executing prepstmnt 1956607135 SELECT SEQUENCE_OWNER AS SEQUENCE_SCHEMA, SEQUENCE_NAME FROM ALL_SEQUENCES
      2203 test TRACE [main] openjpa.jdbc.SQL - <t 1183336072, conn 1912762882> [0 ms] spent
      2422 test TRACE [main] openjpa.jdbc.SQL - <t 1183336072, conn 1594646284> executing stmnt 651896539 CREATE TABLE Department (id NUMBER NOT NULL, name VARCHAR2(255), PRIMARY KEY (id))
      2437 test TRACE [main] openjpa.jdbc.SQL - <t 1183336072, conn 1594646284> [15 ms] spent
      <openjpa-2.0.0-SNAPSHOT-r422266:881772M nonfatal general error> org.apache.openjpa.persistence.PersistenceException: ORA-00955: name is already used by an existing object

      {stmnt 651896539 CREATE TABLE Department (id NUMBER NOT NULL, name VARCHAR2(255), PRIMARY KEY (id))} [code=955, state=42000]
      at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:553)
      at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:453)
      at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:155)
      at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
      at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:117)
      at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:202)
      at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:152)
      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:200)
      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:151)
      at org.apache.openjpa.persistence.lockmgr.TestPessimisticLocks.setUp(TestPessimisticLocks.java:45)
      at junit.framework.TestCase.runBare(TestCase.java:125)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:501)
      at org.apache.openjpa.persistence.test.AbstractPersistenceTestCase.runBare(AbstractPersistenceTestCase.java:477)
      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:177)
      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: org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-00955: name is already used by an existing object
      {stmnt 651896539 CREATE TABLE Department (id NUMBER NOT NULL, name VARCHAR2(255), PRIMARY KEY (id))}

      [code=955, state=42000]
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:254)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$3(LoggingConnectionDecorator.java:251)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:944)
      at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:136)
      at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1202)
      at org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:960)
      at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:537)
      at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:345)
      at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:322)
      at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:501)
      ... 23 more

      If the tables are manually drop, the create table works fine.

      Albert Lee.

      Attachments

        Issue Links

          Activity

            People

              allee8285 Albert Lee
              allee8285 Albert Lee
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: