Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360720 - OuterJoinTest within flashback.FlashbackUnitTestSuite failed on MySQL 5.5.16
Summary: OuterJoinTest within flashback.FlashbackUnitTestSuite failed on MySQL 5.5.16
Status: CLOSED FIXED
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-10-12 15:35 EDT by Kevin Yuan CLA
Modified: 2022-06-09 10:27 EDT (History)
2 users (show)

See Also:


Attachments
Suggested patch. (5.89 KB, patch)
2012-05-09 14:33 EDT, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Yuan CLA 2011-10-12 15:35:32 EDT
One EclipseLink foundation test named OuterJoinTest within flashback.FlashbackUnitTestSuite failed on the latest MySQL (5.5.16), but verified passed on MySQL 5.1.x and 5.5.6. The following are stack trace:

Exception Description: Expected 2 objects, read 1

Local Exception Stack:
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.3.1.v20111008-r10220): org.eclipse.persistence.testing.framework.TestErrorException
Exception Description: Expected 2 objects, read 1
at org.eclipse.persistence.testing.tests.flashback.FlashbackUnitTestSuite.internalOuterJoinTest(FlashbackUnitTestSuite.java:485)
at org.eclipse.persistence.testing.tests.flashback.FlashbackUnitTestSuite._testOuterJoinTest(FlashbackUnitTestSuite.java:464)
at org.eclipse.persistence.testing.framework.UnitTestCase.test(UnitTestCase.java:65)
at org.eclipse.persistence.testing.framework.TestCase.executeTest(TestCase.java:545)
at org.eclipse.persistence.testing.framework.TestCase.execute(TestCase.java:156)
at org.eclipse.persistence.testing.framework.TestCase.runBare(TestCase.java:265)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
at org.eclipse.persistence.testing.framework.TestSuite.execute(TestSuite.java:75)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:211)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:211)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)
at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:211)
at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)
Comment 1 Tom Ware CLA 2011-12-02 10:27:07 EST
Correcting target milestone to next milestone that will include community-submitted bugs.
Comment 2 Andrei Ilitchev CLA 2012-05-09 14:33:18 EDT
Created attachment 215356 [details]
Suggested patch.

The tested query:

Expression expression = builder.getAllowingNull("teamLeader").get("firstName").equal("Sarah");
expression = expression.or(builder.get("name").equal("TOPEmployee Management"));
query.setSelectionCriteria(expression);
query.setAsOfClause(getAsOfClause());

The expected result was 2 LargeProject objects:
one named "TOPEmployee Management", which has no teamLead;
and another one, with a teamLead Sarah.

But when run on MySQL 5.5.16 the test returned only one object - teamLead-less "TOPEmployee Management" was missing.

Here's the generated sql:

SELECT 
	t2.PROJ_ID, t2.PROJ_TYPE, t2.DESCRIP, t2.PROJ_NAME, t2.LEADER_ID, t2.VERSION, t3.PROJ_ID, t3.BUDGET, t3.MILESTONE 
FROM 
	PROJECT_HIST t2 LEFT OUTER JOIN (EMPLOYEE_HIST t0 JOIN SALARY_HIST t1 ON (t1.EMP_ID = t0.EMP_ID)) ON (t0.EMP_ID = t2.LEADER_ID), LPROJECT_HIST t3 
WHERE 
	((((t0.F_NAME = ?) OR (t2.PROJ_NAME = ?)) AND 
	((t3.PROJ_ID = t2.PROJ_ID) AND (t2.PROJ_TYPE = ?))) AND 
	((((t2.ROW_START <= ?) AND ((t2.ROW_END IS NULL) OR (t2.ROW_END > ?))) AND 
	  ((t3.ROW_START <= ?) AND ((t3.ROW_END IS NULL) OR (t3.ROW_END > ?)))) AND 
	((((t0.ROW_START IS NULL) OR (t0.ROW_START <= ?)) AND 
	  ((t0.ROW_END IS NULL) OR (t0.ROW_END > ?))) AND 
	 (((t1.ROW_START IS NULL) OR (t1.ROW_START <= ?)) AND 
	  ((t1.ROW_END IS NULL) OR (t1.ROW_END > ?))))))
	
bind => [
Sarah, TOPEmployee Management, 
L, 
2012-05-07 09:38:49.906, 2012-05-07 09:38:49.906, 
2012-05-07 09:38:49.906, 2012-05-07 09:38:49.906, 
2012-05-07 09:38:49.906, 2012-05-07 09:38:49.906, 
2012-05-07 09:38:49.906, 2012-05-07 09:38:49.906]


As was pointed by James, the problem is putting joining conditions in WHERE clause - those should be in ON clause instead.

Somehow the previous version of MySQL, in case t3.teamLead is null evaluated the joined expression
  ((t0.ROW_START IS NULL) OR (t0.ROW_START <= ?))
to "true", but 5.5.16 - to "false".

The patch moves historical joining conditions from WHERE to ON clause.
Patched Eclipselink generates the following sql:

SELECT 
	t2.PROJ_ID, t2.PROJ_TYPE, t2.DESCRIP, t2.PROJ_NAME, t2.LEADER_ID, t2.VERSION, t3.PROJ_ID, t3.BUDGET, t3.MILESTONE 
FROM 
	PROJECT_HIST t2 LEFT OUTER JOIN (EMPLOYEE_HIST t0 JOIN SALARY_HIST t1 
	ON ((t1.EMP_ID = t0.EMP_ID) AND ((t1.ROW_START <= ?) AND ((t1.ROW_END IS NULL) OR (t1.ROW_END > ?))))) 
	ON ((t0.EMP_ID = t2.LEADER_ID) AND ((t0.ROW_START <= ?) AND ((t0.ROW_END IS NULL) OR (t0.ROW_END > ?)))), LPROJECT_HIST t3 
WHERE 
	((((t0.F_NAME = ?) OR (t2.PROJ_NAME = ?)) AND ((t3.PROJ_ID = t2.PROJ_ID) AND (t2.PROJ_TYPE = ?))) AND 
	(((t2.ROW_START <= ?) AND ((t2.ROW_END IS NULL) OR (t2.ROW_END > ?))) AND 
	((t3.ROW_START <= ?) AND ((t3.ROW_END IS NULL) OR (t3.ROW_END > ?)))))

bind => [
2012-05-09 13:32:26.782, 2012-05-09 13:32:26.782, 
2012-05-09 13:32:26.782, 2012-05-09 13:32:26.782, 
Sarah, TOPEmployee Management, L, 
2012-05-09 13:32:26.782, 2012-05-09 13:32:26.782, 
2012-05-09 13:32:26.782, 2012-05-09 13:32:26.782]

This one correctly returns both objects, the test passes.
Comment 3 Andrei Ilitchev CLA 2012-05-10 14:27:17 EDT
Checked in the fix into trunk (2.4). Reviewed by James.
The bug won't be fixed in 2.3.3 because support for on clause was introduced only in 2.4.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:27:05 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink