I have a sql table A with column names
name, id1, id2, val1
and a table B with column names
id1, id2, key1, key2
and this is my sql query
SELECT
v1.id1,
v1.id2
FROM (
SELECT
A.id1,
A.id2,
min(val1) AS x
FROM A
JOIN B ON A.id1 = B.id1 AND A.id2 = B.id2
GROUP BY A.id1, A.id2
) AS v1
WHERE v1.x > 10
using the DetachedCriteria i was able to form the sub-query
DetachedCriteria subCriteria = DetachedCriteria.forClass(A_model.class);
subCriteria.createAlias("b", "b_model");
subCriteria.setProjection(Projections.projectionList()
.add(Projections.groupProperty("id1"))
.add(Projections.groupProperty("id2"))
.add(Projections.min("val1"),"x");
but i am facing a hard time in creating the outer query.
any suggestion how can i create the criteria for the above SQL?
Thanks in anticipation.