Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349349

Summary: drop table fails if constraints changed
Product: z_Archived Reporter: James Sutherland <jamesssss>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch to drop tables several trys none

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