Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349349 - drop table fails if constraints changed
Summary: drop table fails if constraints changed
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-14 14:05 EDT by James Sutherland CLA
Modified: 2022-06-09 10:34 EDT (History)
1 user (show)

See Also:


Attachments
patch to drop tables several trys (23.93 KB, patch)
2011-06-14 14:25 EDT, James Sutherland CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Sutherland CLA 2011-06-14 14:05:20 EDT
drop-and-create-tables option or SchemaManager replaceTables fails if the database constraints changed.

This occurs frequently in our testing from one version to the other as the test tables have changed.
Comment 1 James Sutherland CLA 2011-06-14 14:08:45 EDT
One partial solution is to attempt to drop all of the tables several times.  This will hopefully remove the tables with constraints and allow the other tables to be dropped.

This will work most of the time, but if a table was removed and still exists on the database and has a constraint on an existing table, it still will not be able to be dropped.

cascade constraints, is another option, but this is only supported by Oracle.

another option may be to query the database metadata, this may be a good long term solution as it could also be used in create-tables to do nothing if the table already exists, and will be required for alter support.
Comment 2 James Sutherland CLA 2011-06-14 14:25:01 EDT
Created attachment 197968 [details]
patch to drop tables several trys
Comment 3 Tom Ware CLA 2012-10-10 10:51:09 EDT
Changing target - missed 2.4.1 release.
Comment 4 James Sutherland CLA 2013-03-19 11:32:04 EDT
I added cascade constraints for Oracle, but still need solution of other dbs.
Comment 5 James Sutherland CLA 2013-03-19 11:32:22 EDT
DB2 always cascades constraints, so is ok.
Comment 6 Tom Ware CLA 2013-04-03 11:22:19 EDT
The JPA 2.1 Spec gives a workaround... Downgrading.
Comment 7 Eclipse Webmaster CLA 2022-06-09 10:34:21 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink