The query is generated with a comma after distinct keyword which is not expected.
Code snippet setting the projection: criteria.setProjection(Projections.countDistinct("id")); final Object result = criteria .setMaxResults(2) .setFirstResult(0).uniqueResult();
Query generated: SELECT TOP (2) count(DISTINCT, this_.tbl_id) AS y0_ FROM tbl this_ WHERE this_.tbl_id2 IN (SELECT tbl.tbl_id2 FROM tbl INNER JOIN tbl2 ON tbl2.tbl2_id = tbl.tbl_id2 WHERE tbl2.tbl2_flg = 'Y' AND tbl2.tbl2_nm = 'abc')
|