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
|