-->
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: Criteria Query: counting results without duplicates
PostPosted: Tue Aug 13, 2013 7:23 am 
Newbie

Joined: Tue Aug 13, 2013 7:01 am
Posts: 1
Hello,

I am trying to count the number of results a criteria query would return, without actually returning them, as this would obviously involve a lot more data being transferred than required. In this case I have a set of tags, which I add as a disjunction to my criteria and I want to find a set of questions which contain these tags. The issue is that no matter how I tried it, the resulting row count always contains duplicates of questions if a question contains more than one of the tags searched for.

When I use criteria.list() to retrieve all results, I avoid duplicates with criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)). This does not seem to work for counting the rows, however.

I have tried counting the rows both with ScrollableResults and getting the row number of the last row and by setting a rowCount projection. Both return incorrect row counts (well, for my purpose incorrect) as they count duplicates.

Is there any way to avoid counting duplicates?

Many thanks in advance!

Cheers,
Jocbe


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.