Quote:
I also tried the following two queries, but those don't work:
SELECT a FROM A a LEFT JOIN a.bs b WITH b.condition = :condition WHERE b IS NULL
This HQL should create something that is similar to the SQL that you say you are looking for... So either the SQL you posted is not generating the correct result either or there is some other details that you have missed (I assume the posted code is a simplification of the real case). I would turn on SQL logging to see what Hibernate really generates and then execute that manually against the database. Then, try to fix the SQL so that the result is correct and as a last step "backport" the fix to the HQL.
Another possibility is to use a simpler subselect that only has to be evaluated once:
Code:
SELECT a FROM A a WHERE a NOT IN (SELECT b.a FROM B b WHERE b.condition = :condition)