[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5785) HQL UPDATE omits alias when referencing an entity

Marcus Ilgner (JIRA) noreply at atlassian.com
Tue Nov 8 12:50:20 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44274#comment-44274 ] 

Marcus Ilgner commented on HHH-5785:
------------------------------------

Just hit the same bug. The entity table that is to be updated does get referenced by auto-generated alias in the sub-select but the alias is never specified on the table itself.

> HQL UPDATE omits alias when referencing an entity
> -------------------------------------------------
>
>                 Key: HHH-5785
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5785
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.3.1
>         Environment: Hibernate 3.3.1 in JBoss AS 5.1.0, org.hibernate.dialect.HSQLDialect
>            Reporter: Ondrej Medek
>
> 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.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list