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:
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
. However its fix would not help with this problem.
A test project is attached.
|