We're updating the issue view to help you get more done. 

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

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:

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

The following queries do work:

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

The following query does not work:

1 2 3 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. However its fix would not help with this problem.

A test project is attached.

Environment

None

Status

Assignee

Gail Badner

Reporter

Oleg Galimov

Components

Fix versions

Priority

Major