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

Rick Curtis commented on OPENJPA-1760:
--------------------------------------

Oli -

I finally got around to reviewing the suggested code change and I don't think 
this is the correct direction to go. Yes the change does make the reported 
problem go away, but there is another big problem that wasn't mentioned.

Per the docs for SchemaTool docs:
 * refresh: Equivalent to retain, then add. 
 * retain: Keep all schema components in the given XML definition, but drop the 
rest from the database. This action never adds any schema components. 
 * add: This is the default action if you do not specify one. It brings the 
schema up-to-date with the given XML document by adding tables, columns, 
indexes, etc. This action never drops any schema components. 

My interpretation of the docs says that retain should drop ALL tables that 
aren't known to OpenJPA. That isn't happening. 

The second problem, and in line with the one you reported is that the 
'deleteTableContents' action is defined to only run against OpenJPA known 
tables. This is a problem with the SchemaTool.getDBSchemaGroup(boolean) method 
and it caches the value returned even though it is dependent on the value of 
the provided boolean. This appears to be a large problem that isn't as simple 
as flipping a single bit. This same problem exists if you were to execute 
'add,deleteTableContents', 'createDB,deleteTableContents', etc.... 
Unfortunately I don't see this being a high enough priority issue to spend any 
more cycles on. Thanks for the patch and feel free to continue to dig into this 
issue if you want.

Thanks,
Rick



> SchemaAction='refresh,deleteTableContents' incorrectly removes data from ALL 
> DB tables.
> ---------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1760
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1760
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: tooling
>    Affects Versions: 2.0.0, 2.1.0
>         Environment: Win XP, Postgres 8.4, OpenJPA 2.0.0 
>            Reporter: Oliver Bayer
>            Assignee: Rick Curtis
>            Priority: Minor
>             Fix For: 2.1.0
>
>         Attachments: OPENJPA-1760_testcase.patch
>
>
> At my usecase not all tables are managed by openjpa so not all of them are 
> listed with the class-tag inside persistence.xml. I set up openjpa to delete 
> the table contents for developping with the following property:
> <property name="openjpa.jdbc.SynchronizeMappings" 
> value="buildSchema(SchemaAction='add,deleteTableContents')"/>
> But now all contents are deleted even the one of tables which aren't listed 
> inside persistence.xml. 
> Shouldn't openjpa only delete contents from tables which are configured plus 
> the openjpa_sequence_table rather than deleting all contents from the whole 
> database? Is this a bug or is there a property which I have to set to get the 
> described behaviour?
> Greets Oli

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