It's all about the answers!

Ask a question

Help with IQueryResult and setting limits

Susan Hanson (1.6k2200194) | asked Dec 26 '13, 11:20 p.m.
I "inherited" some code and in reviewing it, I ended up with a question I was hoping someone could assist me with.

IQueryResult results = getQueryClient().getResolvedQueryResults(query, profile);
int total = validateWorkItemQueryResult(results);
while (results.hasNext(null)) {
        //process the results

The results.setLimit(queryLimit); call is the part that is confusing.  It looks like we have already run the query in the line above, so then would setLimit() do anything at that point?  But if not, then how would I set the limit for the query before running the query itself?


sam detweiler commented Dec 27 '13, 8:04 a.m.

Looking at the code, effectively there has been a Count done when the getResolvedQyeryResults() call is executed, but no results are actually fetched yet.

the setLimit() sets the fetch size. and the fetch is done on the first next().

One answer

permanent link
Susan Hanson (1.6k2200194) | answered Jan 07 '14, 6:26 a.m.
Perfect!  Thanks Sam

Your answer

Register or to post your answer.