openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Bayer (JIRA)" <>
Subject [jira] Commented: (OPENJPA-1698) SchemaAction=deleteTableContents throws error if table doesn't exist
Date Thu, 15 Jul 2010 20:01:49 GMT


Oliver Bayer commented on OPENJPA-1698:

Hi Rick,

thanks for answering. You're right about the not working "IF EXISTS" in postgres. I didn't
thought about it when I posted my suggested bugfix.
Here is the error log (I hope I removed all jsf follow-up errors from my jsf test app):

<openjpa-2.0.0-r422266:935683 nonfatal general error> 
org.apache.openjpa.persistence.PersistenceException: ERROR: Relation »openjpa_sequence_table«
doesn't exist
  Position: 13 {stmnt 8577594 DELETE FROM OPENJPA_SEQUENCE_TABLE} [code=0, state=42P01]
	at org.apache.openjpa.jdbc.meta.MappingTool.record(
	at org.apache.openjpa.jdbc.meta.MappingTool.record(
	at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(
	at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(
	at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(
	at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(
	at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
	at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(
... 27 more

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.deleteTableContents(
	at org.apache.openjpa.jdbc.meta.MappingTool.record(
	... 45 more

The error message "ERROR: Relation »openjpa_sequence_table« doesn't exist" comes directly
from postgres. I get the same one if I try to execute the delete statement (shown above) inside
the postgres sql editor.


> SchemaAction=deleteTableContents throws error if table doesn't exist
> --------------------------------------------------------------------
>                 Key: OPENJPA-1698
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.0.0
>         Environment: Win XP, Postgres 8.4, OpenJPA 2.0.0
>            Reporter: Oliver Bayer
> Hi,
> I want to set up my project during development so that all table contents are deleted
with the following property in persistence.xml:
> <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction=add,SchemaAction=deleteTableContents)"/>
> If I start up with an empty database I get the following error:
> org.apache.openjpa.persistence.PersistenceException: ERROR: Relation >>openjpa_sequence_table<<
doesn't exist.
> This error is raised because of the following sql statement: DELETE FROM OPENJPA_SEQUENCE_TABLE.
> My suggested solution would be to modify DBDictionary.getDeleteTableContentsSQL so that
it only deletes content from a table if the table exists.
> DBDictionary: Line 2183
> ---------------------------------
> change: deleteSQL.add("DELETE FROM " + toDBName(tables[i].getFullIdentifier()));
> to: deleteSQL.add("DELETE FROM " + toDBName(tables[i].getFullIdentifier()) + " IF EXISTS");
> What do you mean: Is this a valid bugfix? I'm looking forward to your responses.
> Greets Oli

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

View raw message