openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Bayer (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-1698) SchemaAction=deleteTableContents throws error if table doesn't exist
Date Mon, 19 Jul 2010 20:46:52 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-1698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12890017#action_12890017
] 

Oliver Bayer commented on OPENJPA-1698:
---------------------------------------

Hi Rick,

for me it seems that this is an overall issue not just a postgres one.

I tried to execute the delete statement (DELETE FROM OPENJPA_SEQUENCE_TABLE) on a mysql db
and got the same error:
#1146 - Table 'mytestdb.openjpa_sequence_table' doesn't exist

I'm relatively new to openjpa and don't know the the framework in detail so you have to check
if one of the following suggestions are implementable :-):

1) Run the SchemaAction=deleteTableContents as the very last statement. This way the OPENJPA_SEQUENCE_TABLE
would have been already created by e.g. the SchemaAction=add call and thus the delete statement
will work.

2) DBDictionary.getDeleteTableContentsSQL: the tables parameter should only contain tables
which exist already e.g. only add tables to the list if "SELECT * FROM xyz LIMIT 1" returns
a resultset. If there is a "doesn't exist" error thrown ignore this table and check the next
one.

3) During the execution of the delete statement check for "doesn't exist" errors but ignore
them. The execution shouldn't stop but move to the next table and try the delete statement.

I hope you can use at least one of them to solve the issue.

Greets Oli

> SchemaAction=deleteTableContents throws error if table doesn't exist
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-1698
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1698
>             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.


Mime
View raw message