I have following sql which I want to express with Criteria, but don't know how to do it:
select a.id
from a, ao, o
where a.id=ao.a_id and ao.o_id=o.id and o.id in (?) and o.t_id in (?)
group by a.id having count(a.id)=?
Please help!
Actually above mentioned is just the subquery, the full SQL I want is
select * from a where <restriction on some other properties of a> and a.id in (above mentioned sql)
Right now I have a Criteria with various restrictions on other properties of a, combined with Restrictions.sqlRestriction(above mentioned sql). It works, but I really would like to get rid off the hardcoded SQL.
Your help is greatly appreciated.
|