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

Jody Grassel updated OPENJPA-816:
---------------------------------

    Attachment: openjpa-816.zip

Simple JUnit test, just configure the properties in persistence.xml and give it 
a try.  You'll need to run Oracle twice, unless you already have a table 
"Customer" already in your database.

> 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
>         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.

Reply via email to