Hibernate Criteria Query to outer join sub-queries results

1k views Asked by At

I have a requirement to convert the below SQL query into a criteria query. There is just one table and note that it is not a case for self join.

SELECT atable.c1 AS ac1, btable.c1 as bc1 
  FROM (
       SELECT a.c1 
         FROM table_child a 
        WHERE a.c2='XXX') atable 
       LEFT OUTER JOIN (
           SELECT b.c1 
             FROM table_child b 
            WHERE b.c3 ='YYYYY') btable 
       ON atable.c1 = btable.c1 

I am aware of how to use DetachedCriteria using org.hibernate.criterion.Subqueries to do things like IN(), NOT EXISTS(), etc. But the SubQueries class seems to be mainly for WHERE clause.

How do I use a SubQuery to perform a join as shown in the above SQL query. I need to do this using Hibernate Criteria Query.

Thanks.

0

There are 0 answers