You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Albert Lee (JIRA)" <ji...@apache.org> on 2010/09/29 21:37:33 UTC

[jira] Resolved: (OPENJPA-816) With Oracle, PU's with SynchronizeMappings="buildSchema(ForeignKeys=true)" fail with error stating table already exists

     [ https://issues.apache.org/jira/browse/OPENJPA-816?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Albert Lee resolved OPENJPA-816.
--------------------------------

      Assignee: Albert Lee
    Resolution: Not A Problem

This condition is caused by the use of SYSTEM or any system schema/user as defined in systemSchemaSet in the OracleDictionary and if the associaed table already exists in the db.

What happened is, if buildSchema is specified in synchronizedMapping or MappingTool is used to add table to the db, the mapping tools first scan and find the table from the schema set. but filter out all the table with any system schema specified in the set in SchemaGenerator.generateTables. As a result, the generator don't "see" the table in the db and try to recreate it. However the table exists in the db and hence the observed error.


> With Oracle, PU's with SynchronizeMappings="buildSchema(ForeignKeys=true)" fail with error stating table already exists
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-816
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-816
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.2.0
>         Environment: Running in Eclipse, Oracle 10.2
>            Reporter: Jody Grassel
>            Assignee: Albert Lee
>         Attachments: openjpa-816.zip
>
>
> I hit a curious problem with using the <name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"> property with Oracle 10.2.  The first time I ran my JPA application (it just populates and deletes rows in a single table), it ran fine, as the table did not previously exist on the Oracle DB server.  Successive invocations of the test application fail with the following message:
> <openjpa-1.2.1-SNAPSHOT-r422266:686069 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: ORA-00955: name is already used by an existing object
>  {stmnt 863712123 CREATE TABLE Customer (id NUMBER NOT NULL, customerId NUMBER, firstName VARCHAR2(255), lastName 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:159)
> 	at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:119)
> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:189)
> 	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
> 	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
> 	at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:42)
> 	at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:27)
> 	at ostoredproc.tests.StoredProcTest.setUp(StoredProcTest.java:50)
> 	at junit.framework.TestCase.runBare(TestCase.java:128)
> 	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:120)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:230)
> 	at junit.framework.TestSuite.run(TestSuite.java:225)
> 	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 863712123 CREATE TABLE Customer (id NUMBER NOT NULL, customerId NUMBER, firstName VARCHAR2(255), lastName VARCHAR2(255), PRIMARY KEY (id))} [code=955, state=42000]
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57)
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:762)
> 	at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:114)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1191)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.createTable(SchemaTool.java:949)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:526)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:344)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:321)
> 	at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:501)
> 	... 22 more
> I switched databases to DB2, and this problem did not occur.  So it seems that the mapping tool is not able to accommodate existing tables with Oracle -- it bails out immediately, even if the existing table's schema matches the entity's structure.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.