HQL UPDATE omits alias when referencing an entity

Description

HQL UPDATE:

UPDATE Lesson e SET e.state = 'N' WHERE EXISTS (SELECT 1 FROM LessonOrder lso WHERE lso.lesson = e)

produces wrong SQL:

update LESSON set lsn_state='N' where exists (select 1 from LESSON_ORDER lessonorde1_ where lessonorde1_.lsn_id=lsn_id)

since in the database exists columns if the same name: LESSON.lsn_id and LESSON_ORDER.lsn_id. The problem is, that Hibernate omits the alias "e" in the SQL. When I make a little different query:

UPDATE Lesson e SET e.state = 'N' WHERE EXISTS (SELECT 1 FROM LessonOrder lso WHERE lso.lesson.id = e.id)

then the resulting SQL is right:

update LESSON set lsn_state='N' where exists (select 1 from LESSON_ORDER lessonorde1_ where lessonorde1_.lsn_id=LESSON.lsn_id)

However, I think the Hibernate should not omit the alias "e" in either case.

Environment

Hibernate 3.3.1 in JBoss AS 5.1.0, org.hibernate.dialect.HSQLDialect

Activity

Show:
Brett Meyer
September 29, 2014, 10:44 PM

, certainly. The issue is now re-opened, so you should be able to attach above.

Radoslaw Madej
September 29, 2014, 11:03 PM

Bug is reproduced by HQLTest.test() method.

Steve Ebersole
October 28, 2015, 6:15 AM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve Ebersole
October 28, 2015, 2:25 PM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Christian Beikov
October 31, 2015, 1:35 AM

I know this is a duplicate but I can't find the other issue right now.

Assignee

Unassigned

Reporter

Ondrej Medek

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major