cancel
Showing results for 
Search instead for 
Did you mean: 

Task Instance Count Wrong Result

doganmesut
Champ in-the-making
Champ in-the-making
Hi  friends,
We are facing an issue  while querying number of historic task instaces.
A piece of code block for example  :

List list = historyService.createHistoricTaskInstanceQuery()
                    .taskAssignee(candidateOrAssignedUser.toString()).taskDeleteReason("completed").finished().list();
int count = list.size();

if we want to get size of list , result is expected but list.size() is useless for us because of performance issue.
We want to use count() method instead of list() method, like below :

int count = historyService.createHistoricTaskInstanceQuery()
                    .taskAssignee(candidateOrAssignedUser.toString()).taskDeleteReason("completed").finished().count();

But these two approaches doesnt match and there is a huge difference. For example list.size() returns 195 results and count() return 425 results.
I will be glad if aynone helps me .
Thank you very much.

PS : Please also note that this situation is the same for querying running task inctances.
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi doganmesut,

Can you reproduce the issue in the jUnit test? https://forums.activiti.org/content/sticky-how-write-unit-test
(there are plenty of tests testing exactly your case in activiti source)

Regards
Martin

doganmesut
Champ in-the-making
Champ in-the-making
It is not possible to reproduce . Because it is a kind of strange behavour. Maybe it i a  bug that we have produced.
Last question is ; Are expected return values which comes from .xxxqueryxxx.count() method and xxxqueryxxx.list().size() supposed to be same  ?

ilalaina
Champ in-the-making
Champ in-the-making

doganmesut
Champ in-the-making
Champ in-the-making
It seems same issue.

trademak
Star Contributor
Star Contributor
With includeProcessInstanceVariables or includeTaskVariables the size can be off, this is also described in the query API method. But in this case the variables are not included. The count query is exactly the same as the result query, so the size values should be the same. It's difficult to look into this without a unit test showing the issue.

Best regards,