Hi all,
Hope this is not noise, did looked at various places for a solution on this,
How can i query rowCount for a criteria which already has projection set ?
Ex:
criteria.createAlias("assoPath1", "alias1", CriteriaSpecification.INNER_JOIN)
.createAlias("assoPath2", "alias2", CriteriaSpecification.INNER_JOIN)
.setProjection(Projections.projectionList() .add(Property.forName("alias1.name").group().as("alias1Name"))
.add(Property.forName("alias2.name").group().as("alias2Name"))
.add(Property.forName("col").count().as("count"))
);
lets say this query translates to
select assoPath1Table.name as y0_, assoPath2Table.name as y1_, count(this_.col) as y2_ from this_table this_ inner join asso_path_1_table assoPath1Table on this_.fk_1=assoPath1Table.key inner join assoPath1Table asso_path_2_table assoPath2Table on this_.fk2=assoPath2Table.key group by assoPath1Table.name, assoPath2Table.name
What i am looking is for count of this query
for ex on MSSQL server the query is:
select count(*) from (select assoPath1Table.name as y0_, assoPath2Table.name as y1_, count(this_.col) as y2_ from this_table this_ inner join asso_path_1_table assoPath1Table on this_.fk_1=assoPath1Table.key inner join assoPath1Table asso_path_2_table assoPath2Table on this_.fk2=assoPath2Table.key group by assoPath1Table.name, assoPath2Table.name)
the basic thing here is can i do this with hibernate, please suggest if its possible.
Thank you in advance.
Regards
K
|