Volker Seibt (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a4ea7a...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYzkzYmRiZWJm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16003?atlOrigin=eyJpIjoiYzkzYm...
) HHH-16003 (
https://hibernate.atlassian.net/browse/HHH-16003?atlOrigin=eyJpIjoiYzkzYm...
) Wrong alias used in subquery generated from JPQL (
https://hibernate.atlassian.net/browse/HHH-16003?atlOrigin=eyJpIjoiYzkzYm...
)
Change By: Volker Seibt (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a4ea7a...
)
For this JPQL
{code:java}select mdf.id from MasterDataFileEntity mdf
where mdf.dataImportStatus = 'SUCCESS'
and mdf.metaData.country = :countryCode
and mdf.metaData.transportMode = :transportMode
and mdf.metaData.product = :product
and mdf.importFinishedAt =
(select max(mdf.importFinishedAt) from MasterDataFileEntity mdf
where mdf.dataImportStatus = 'SUCCESS'
and mdf.metaData.country = :countryCode
and mdf.metaData.transportMode = :transportMode
and mdf.metaData.product = :product){code}
Hibernate generates this SQL
{code:sql}select m1_0.id from PEL.pel_master_data_file m1_0
where m1_0.data_import_status='SUCCESS'
and m1_0.country_code=?
and m1_0.transport_mode=?
and m1_0.product=?
and m1_0.import_finished_at=
(select max(m2_0.import_finished_at) from PEL.pel_master_data_file m2_0
where m2_0.data_import_status='SUCCESS'
and m1_0.country_code=?
and m1_0.transport_mode=?
and m1_0.product=?){code}
The table alias for the subquery for all conditions joined by {{and}} is wrong, taken not
from the subquery but from the main query.
Workaround is to use a different alias for the subquery in JPQL.
Test case:
[
https://github.com/vseibt/hibernate-test-case-templates/commit/405bc954f7...]
(
https://hibernate.atlassian.net/browse/HHH-16003#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16003#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100213- sha1:1fa7b87 )