Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 245655 - Discrepancy beteen SQL Result and JPA QL Result
Summary: Discrepancy beteen SQL Result and JPA QL Result
Status: RESOLVED DUPLICATE of bug 246211
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-29 04:45 EDT by Markus KARG CLA
Modified: 2022-06-09 10:24 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus KARG CLA 2008-08-29 04:45:57 EDT
Build ID: N/A

Steps To Reproduce:
When running this SQL:

SELECT Cause.causingCostCentreId, COUNT(DISTINCT DiscoveredMistake.mistakeId)
FROM Complaint JOIN ComplaintSubject LEFT JOIN Clarification LEFT JOIN
DiscoveredMistake LEFT JOIN Cause LEFT JOIN SeizedMeasure LEFT JOIN OccuredCost
GROUP BY Cause.causingCostCentreId

There is this result:

'AAA': 1
'Support': 0
(NULL): 6
'BBB': 0

When running the equivalent JPA QL:

SELECT ca.causingCostCentre.pk.id, COUNT(DISTINCT dm.mistake.pk.id) FROM
Complaint cp JOIN cp.complaintSubject cs LEFT JOIN cp.clarifications cf LEFT
JOIN cf.discoveredMistakes dm LEFT JOIN dm.causes ca LEFT JOIN ca.seizedMeasures
sm LEFT JOIN sm.occuredCosts oc GROUP BY ca.causingCostCentre.pk.id

Then the result is just one line:

'AAA': 1

I wonder why the lines 'Support: 0' and 'BBB: 0' are not provided?


More information:
Bug originally reported to TopLink: https://glassfish.dev.java.net/issues/show_bug.cgi?id=5644
Comment 1 Chris Delahunt CLA 2008-09-03 11:01:32 EDT
Hello,

Can you please provide the SQL generated from the JPA QL, and give either a test case or describe the relationships used in the joins so that we can reproduce the problem for testing.  As you filed this originally on TopLink Essentials, can you please also confirm that it exists in EclipseLink?  
Comment 2 Markus KARG CLA 2008-09-04 10:28:07 EDT
Yes the problem also occurs in EclipseLink. The SQL showed that the problem is that a INNER JOIN is created that "eats up" NULL rows, leading to the discrepancy between SQL and JPA QL result lists.

I have drilled down the problem to the core and opened another bug report describing the cause of the problem. Please see bug report #246211.
Comment 3 Chris Delahunt CLA 2008-09-04 14:03:21 EDT
closing as a duplicate of 246211.

In this case, dm.mistake.pk.id is specifying an Inner join between DM and Mistake.  This is why null mistake values will not be included in the results.

*** This bug has been marked as a duplicate of bug 246211 ***
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:24:02 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink