Volker Seibt (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a4ea7a...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOGMyOTY0NDBh...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16003?atlOrigin=eyJpIjoiOGMyOT...
) HHH-16003 (
https://hibernate.atlassian.net/browse/HHH-16003?atlOrigin=eyJpIjoiOGMyOT...
) Wrong alias used in subquery generated from JPQL (
https://hibernate.atlassian.net/browse/HHH-16003?atlOrigin=eyJpIjoiOGMyOT...
)
Issue Type: Bug Affects Versions: 6.1.6 Assignee: Unassigned Components: hibernate-core
Created: 09/Jan/2023 01:17 AM Priority: Major Reporter: Volker Seibt (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a4ea7a...
)
For this JPQL
Unable to find source-code formatter for language: jpql. Available languages are:
actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell,
html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow,
ruby, scala, sh, sql, swift, visualbasic, xml, yaml
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)
Hibernate generates this 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=?)
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.
(
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 )