Steffen Schäfer (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5f1ef7e...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYWI5NTk2ODc0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16615?atlOrigin=eyJpIjoiYWI5NT...
) HHH-16615 (
https://hibernate.atlassian.net/browse/HHH-16615?atlOrigin=eyJpIjoiYWI5NT...
) SQL query accesses non-existing alias in update/delete (
https://hibernate.atlassian.net/browse/HHH-16615?atlOrigin=eyJpIjoiYWI5NT...
)
Issue Type: Bug Affects Versions: 6.2.2 Assignee: Unassigned Created: 16/May/2023 07:00 AM
Priority: Major Reporter: Steffen Schäfer (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5f1ef7e...
)
With the update from hibernate 5.6 to 6.2 some of our update and delete queries cause
invalid SQL to be generated. In all cases there’s an alias used in the where clause which
isn’t declared. This occurs in cases the query contains a condition which refers to a
relation of the entity to update/delete.
The JPQL query
UPDATE PrivateSubData psd set psd.dataName = '...' where psd.data.person.id = ?1
is translated to SQL as
update private_sub_data set data_name='...' where d1_0.person_id=?
We were able to create a reproducer with 3 entities. In our production code, this also
occurs in cases with only 2 entites which do not require any join or inner select. We
could not reproduce this case in a simple code base.
A reproducer can be found at
https://github.com/steffen-schaefer/hibernate-alias
(
https://hibernate.atlassian.net/browse/HHH-16615#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16615#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#100225- sha1:6805d32 )