I have a requirement to convert the following SQL query to a criteria query. There is only one table and note that this 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 know how to use DetachedCriteriawith org.hibernate.criterion.Subqueriesto do things like IN(), NOT EXISTS()etc. But the class SubQueriesseems to be mainly related to the sentence WHERE.
How to use SubQuery to perform a join, as shown in the above SQL query. I need to do this using the Hibernation Criteria query.
Thank.
source
share