I’m having trouble getting a viable query where I can have multiple required records and a single “one of two” exists.
I’m using Hibernate, hql, the sql obviously wouldn’t be radically different, but it means that I can’t use a full join (and therefore awkward).
What I basically want, but can’t because I don’t know how to mix inner and out exist calls :
select 1
from application
where
application = ? and
exists (select 1 from x where ...) and
exists (select 1 from y where ...) and
exists ((exists (select 1 from Document where ...))
or
(exists (select 1 from QA answer where ...)))
So I need x & y, but either Document or QA can be acceptable, as long as 1 exists.
Something like this?