You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Will Dazey (JIRA)" <ji...@apache.org> on 2017/10/19 20:16:00 UTC
[jira] [Created] (OPENJPA-2721) Table drops can use wrong default
schema
Will Dazey created OPENJPA-2721:
-----------------------------------
Summary: Table drops can use wrong default schema
Key: OPENJPA-2721
URL: https://issues.apache.org/jira/browse/OPENJPA-2721
Project: OpenJPA
Issue Type: Bug
Components: jpa
Affects Versions: 2.2.2
Reporter: Will Dazey
Assignee: Will Dazey
Priority: Minor
It looks like OpenJPA will drop tables from the wrong schemas if the default schema is not set by the persistence property or the orm.xml mapping.
For example:
DB Tables:
unknown_schema.SIMPLE_ENTITY
Properties:
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true,schemaAction='drop,add')"/>
If the default schema is not set as described above and your DS is connected using dbadmin. OpenJPA will find the table SIMPLE_ENTITY in the schema "unknown_schema", but will then throw the following exception (on DB2):
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DBADMIN.SIMPLE_ENTITY, DRIVER=4.8.87 {stmnt 414359678
DROP TABLE SIMPLE_ENTITY } [code=-204, state=42704]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:219)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:203)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:59)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:914)
at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:118)
at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1224)
at org.apache.openjpa.jdbc.schema.SchemaTool.dropTable(SchemaTool.java:985)
at org.apache.openjpa.jdbc.schema.SchemaTool.dropTables(SchemaTool.java:959)
at org.apache.openjpa.jdbc.schema.SchemaTool.drop(SchemaTool.java:872)
at org.apache.openjpa.jdbc.schema.SchemaTool.drop(SchemaTool.java:375)
at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:345)
The issue is that OpenJPA does not use the correct schema when scanning for tables to drop. This should be an issue on all platforms, but I was only able to test on DB2, Oracle, MySQL,
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)