openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Dazey (JIRA)" <>
Subject [jira] [Created] (OPENJPA-2721) Table drops can use wrong default schema
Date Thu, 19 Oct 2017 20:16:00 GMT
Will Dazey created OPENJPA-2721:

             Summary: Table drops can use wrong default schema
                 Key: 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: 

<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,
DROP TABLE SIMPLE_ENTITY } [code=-204, state=42704]
	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(
	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(
	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(
	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(
	at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(
	at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(
	at org.apache.openjpa.jdbc.schema.SchemaTool.dropTable(
	at org.apache.openjpa.jdbc.schema.SchemaTool.dropTables(
	at org.apache.openjpa.jdbc.schema.SchemaTool.drop(
	at org.apache.openjpa.jdbc.schema.SchemaTool.drop(

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

View raw message