Eclipselink 2.6.4 LEFT JOIN TREAT QUERY Not working properly [message #1749385] |
Tue, 06 December 2016 07:38 |
Nuno Godinho de Matos Messages: 34 Registered: September 2012 |
Member |
|
|
Hi.
I have detected that the "TREAT" feature in eclipse link 2.6.4 seems not to be working properly, at least in respect to left join queries.
Right now I do not have a sample application that I can provide you but I can summarize the behavior.
On upgrade from JEE 6 to JEE 7 library versions and moving to eclipselink 2.6.4 from the 2.4.x, the following behavior was found.
A Query of the from:
SELECT A
FROM Entity a
LEFT JOIN TREAT(a.parent AS B) b
The query does not return any results when our related entity "B" is null.
This is of course not correct behavior because we are doing a LEFT JOIN.
So if a.Parent is null but a exists, we want results to come out.
The reason why such as query in eclipselink 2.6.4 does not work is because, when you look at the NativeSQL of the produced query, a predicate of the following is in the query:
AND
(
-- this is our @DiscriminatorValue("B")
t10.CLASS_TYPE = 'CLASSIFIER_OF_TYPE_B'
)
In order for the LEFT JOIN to be logical correct, the TREAT should not have induced the injection of:
b.CLASS_TYPE = @DiscriminatorValue("B")
but instead it should have injected as predicates into the native SQL something of the form:
b.CLASS_TYPE = @DiscriminatorValue("B")
OR b.CLASS_TYPE IS NULL.
In the LEFT JOIN scenario.
I have compared with the Native sql of the Older eclipse link version 2.4.x.
There, the predicate simply was not added.
In both implementations the compilation into Native SQL was not logically correct, but in the 2.6.4 this change in behavior is causing many queries to break.
Please let me know if a Sample application for this is absolutely needed, if so I will make one.
But I am confident that the people that know of JPQL to NATIVE SQL compilation can figure out if this bug is true or not in a few minutes.
So I doubt there is any need to provide a sample application for this.
Kind regards.
[Updated on: Tue, 06 December 2016 07:41] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03176 seconds