EclipseLink - ordering of tables for join statement [message #479718] |
Wed, 12 August 2009 07:40 |
Ricky Messages: 204 Registered: July 2009 |
Senior Member |
|
|
Hi all,
I have encountered a problem when using EclipseLink 1.1.1 to translate the
following JPA query into native query.
"SELECT e FROM Employee e, Department d WHERE d.mgrId = e.id and
d.mgrCountryId = e.countryId"
It was translated into the following query.
"SELECT el_employee.id, el_employee.name ... FROM el_department t0,
el_employee t1 WHERE ((t0.mgr_id = t1.id) AND (t0.mgr_country_id =
t1.country_id))"
Instead of using "t1" as prefixes in the SELECT clause, table name
"el_employee" was used as prefixes.
It is interesting that if I change the ordering of the tables (reverse the
order) in the FROM clause as follow,
"SELECT e FROM Department d, Employee e WHERE d.mgrId = e.id and
d.mgrCountryId = e.countryId"
The query was correctly translated.
"SELECT t0.id, t0.name ... FROM el_employee t0, el_department t1
WHERE((t1.mgr_id = t0.id) AND (t1.mgr_country_id = t0.country_id))"
The query was also correctly translated if the SELECT clause was changed
to
"SELECT e.id FROM Employee e, Department d WHERE d.mgrId = e.id and
d.mgrCountryId = e.countryId"
It was translated into,
"SELECT t0.id FROM el_employee t0, el_department t1 WHERE ((t1.mgr_id =
t0.id) AND (t1.mgr_country_id = t0.country_id))"
It seems that the problem only occurred when the ordering of the tables in
FROM clause is different from the ordering of the prefixes in the WHERE
clause (join condition). Is it a bug in EclipseLink or I have missed out
something?
Best Regards,
Ricky
|
|
|
|
Powered by
FUDForum. Page generated in 0.04416 seconds