views:

109

answers:

0

Hi,

Is it possible to use HQL/ICritera to produce a query with the same semantics as the following SQL query:

select table1.A, table2.B, count(*) from table1 
  left join (select table2.parent_id, table2.B from table2 where table2.C = 'Some value') as table2
on table2.parent_id = table1.id
group by table1.A, table2.B
order by table1.A

In particular, what I'd like is to receive rows (that is, objects) from table1 that have no matching rows in table2. However, I only get the rows from table1 that have matches in table2. Is this the meaning of 'LEFT JOIN' in HQL? And if so, how can I get it to join on a subquery?

Tnx.

Edit: Just to clarify, table1 has a one-to-many (ISet<>) mapping to table2.