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.
The following queries do work:
The following query does not work:
The same problem existed in NHibernate and was fixed:
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.