Uploaded image for project: 'Hibernate ORM'
  1. HHH-9090

HQL: parser is trying to reuse parent implied join for subquery

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      A query with two conditions in the where clause doesn't work, if the first clause references a field of a one-to-one related table and the second is a subquery that references a different field of the same table in its from clause.

      Example:

      TestClass1 <--one to one--> TestClass2 <-one to many-> TestClass3
      

      The following queries do work:

      from TestClass1 as testClass1
      where exists (from testClass1.testClass2.testClass3Set as testClass3 where testClass3.name = 'test3first')
      
      from TestClass1 as testClass1 
      where testClass1.testClass2.title='test2'
      

      The following query does not work:

      from TestClass1 as testClass1 
      where testClass1.testClass2.title='test2' and 
      exists (from testClass1.testClass2.testClass3Set as testClass3 where testClass3.name = 'test3first')
      

      The same problem existed in NHibernate and was fixed:
      https://nhibernate.jira.com/browse/NH-3002
      This solution worked for me.

      Also a similar bug is HHH-3749 Closed . However its fix would not help with this problem.

      A test project is attached.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 1h
                  1h