Hallo,
maybe i do not understand the correct usage of Projections: what I would like to do is something like:
Code:
SELECT count(*)
FROM
(SELECT this_.ADDRESS_PROVINCE_CODE as y0_,
count(DISTINCT this_.ADDRESS_PROVINCE_CODE) as y1_
FROM WMS_SUPPLIER this_
WHERE this_.ADDRESS_PROVINCE_CODE like ?
GROUP BY this_.ADDRESS_PROVINCE_CODE
)
With the following chunk of code I manage to generate the subquery:
Code:
Session sess = (Session) si.getServerSession();
Criteria crit = sess.createCriteria(Supplier.class);
crit.add(Expression.like("addressProvince.id.code", "%M%"));
ProjectionList projections = Projections.projectionList();
projections.add(Projections.alias(Projections
.groupProperty("addressProvince.id.code"), "province"));
projections.add(Projections.alias(Projections
.countDistinct("addressProvince.id.code"), "tot"));
crit.setProjection(projections);
List l = crit.list();
I would like to know how many groups there are, so I would like to insert this aggregated query, in a count projection.
Thanks a lot.
Marco