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

Bug 289023

Summary: JUnit tests create/drop constraints even if supportsUniqueKeyConstraints is false
Product: z_Archived Reporter: Dies Koper <dieskun>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch for bugs 289019-289023 none

Description Dies Koper CLA 2009-09-09 21:31:25 EDT
Some JUnit tests have SQL statement hard-coded to drop and add constraints. These are executed even if the platform does not support constraints (or does not support dropping/adding them through ALTER TABLE, as in Symfoware's case), giving errors.

If not important to the purpose of the test, adding a platform supportsUniqueKeyConstraints check around these statements will allow these tests to be included in (regression) testing for Symfoware.

It might be easier to just do a search for "ALTER TABLE ", but I'll list my hits here:

eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/advanced/compositepk/CompositePKTableCreator.java (2 matches)
750: session.executeNonSelectingSQL("Alter table CMP3_SCIENTIST drop constraint CMP3_SCIENTIST_CUBICLE");
751: session.executeNonSelectingSQL("Alter table CMP3_SCIENTIST drop constraint CMP3_SCIENTIST_DEPT");

inheritance/InheritanceTableCreator.java
1,674: session.executeNonSelectingSQL("Alter table CMP3_ENGINEER_LAPTOP drop constraint CMP3_ENGINEER_LAPTOP_FK1");

xml/advanced/compositepk/CompositePKTableCreator.java (2 matches)
335: session.executeNonSelectingSQL("Alter table CMP3_XML_SCIENTIST drop constraint CMP3_XML_SCIENTIST_CUBICLE");
336: session.executeNonSelectingSQL("Alter table CMP3_XML_SCIENTIST drop constraint CMP3_XML_SCIENTIST_DEPT"); 

eclipselink.core.test/src/org/eclipse/persistence/testing/framework/LoadBuildSystem.java (4 matches)
96: session.executeNonSelectingCall(new SQLCall("ALTER TABLE RESULT ADD CONSTRAINT FK_RESULT_summaryId FOREIGN KEY (summaryId) REFERENCES SUMMARY (id)"));
97: session.executeNonSelectingCall(new SQLCall("ALTER TABLE RESULT ADD CONSTRAINT FK_RESULT_lbuildId FOREIGN KEY (lbuildId) REFERENCES LOADBUILD (id)"));
98: session.executeNonSelectingCall(new SQLCall("ALTER TABLE SUMMARY ADD CONSTRAINT FK_LOADBUILD_lbuildId FOREIGN KEY (lbuildId) REFERENCES LOADBUILD (id)"));
99: session.executeNonSelectingCall(new SQLCall("ALTER TABLE SUMMARY ADD CONSTRAINT FK_LOADBUILD_parentId FOREIGN KEY (parentId) REFERENCES SUMMARY (id)"));

models/inheritance/InheritanceSystem.java (6 matches)
121: session.executeNonSelectingSQL("Alter TABLE PROJECT_WORKER_BATCH DROP CONSTRAINT PROJECT_WORKER_BATCH_HD");
122: session.executeNonSelectingSQL("Alter TABLE PROJECT_BATCH DROP CONSTRAINT PROJECT_WORKER_BATCH_FK");
123: session.executeNonSelectingSQL("Alter TABLE ALLIGATOR DROP CONSTRAINT FK_ALLIGATOR_VICTIM_ID");
124: session.executeNonSelectingSQL("Alter TABLE PERSON2 DROP CONSTRAINT PERSON2_PERSON2_FRND");
125: session.executeNonSelectingSQL("Alter TABLE PERSON2 DROP CONSTRAINT PERSON2_PERSON2_REP");
126: session.executeNonSelectingSQL("Alter TABLE PERSON2 DROP CONSTRAINT PERSON2_PERSON2_BS");

ownership/OwnershipSystem.java (2 matches)
38: session.executeNonSelectingSQL("Alter TABLE OBJECT_A DROP CONSTRAINT OWNER_A_ONE_TO_ONE_");
39: session.executeNonSelectingSQL("Alter TABLE OBJECT_C DROP CONSTRAINT OWNER_C_ONE_TO_ONE_");

I will not attach a patch as you would be in a better position to make the call
whether the constraints are important to each test.
Comment 1 Tom Ware CLA 2009-09-11 16:27:21 EDT
Created attachment 147002 [details]
Patch for bugs 289019-289023
Comment 2 Tom Ware CLA 2009-09-11 16:28:58 EDT
Checked in fix for bug 289019, bug 289020, bug 289021 and bug 289023

These fixes are changes suggested by the bug filer and are reasonably simple.

I have reviewed the changes as they were added and run the existing tests to ensure they do not break anything.
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:03:29 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink