-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Count on a criteria which has count itself (difficult)
PostPosted: Thu Oct 12, 2006 1:00 pm 
Newbie

Joined: Thu Oct 12, 2006 12:38 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.