cancel
Showing results for 
Search instead for 
Did you mean: 

TaskQuery count mismatch

agarwalnitish18
Champ in-the-making
Champ in-the-making

HI,

I am using activti 5.21 and executing th below query.

query = taskService.createTaskQuery().taskCategory("incomplete").active().orderByTaskCreateTime().desc()
.includeProcessVariables();

if i do query.count(),its returning me count as 667, but when i do quey.list().size(), its returning me 376.

I am new to activiti.Please help me understand what is causing the above scenario.

2 REPLIES 2

romschn
Star Collaborator
Star Collaborator

Kindly take a look at  , it looks similar.

Hope this helps.

thuynh
Star Contributor
Star Contributor

Hi agarwalnitish18 _ 

Per java doc of TaskQuery and TaskInfoQuery (TaskInfoQuery (Activiti - Engine 5.22.0 API), taskQuery.taskCategory(String category) will allow the query to search for tasks with the given category only. The task category is defined within the task attribute as follows

Task category defined in GUI

task category defined in XML

So a query such as this should return all tasks that has category 'review' and are active. 

query = taskService.createTaskQuery().taskCategory("review").active().orderByTaskCreateTime().desc()
.includeProcessVariables();

 

Your query doesn't look correct except you do have category 'incomplete' defined for your tasks which doesn't sound right. I believe you are looking for active tasks which is already handled by .active(). 

Per Activiti java doc (Query (Activiti - Engine 5.22.0 API) , count() will run your query and return the number of results and list() will return the list of entities the query could find. So they should return the same number. I attached my unit test which shows taskQuery.count() and taskQuery.list.size() returns the same value. Here's a snippet of the unit test log. I attached the full log as well.

INFO: Initializing process instance: 5
INFO: Initializing process instance: 21
Jan 04, 2017 1:21:40 PM java.util.logging.LogManager$RootLogger log
INFO: Process execution: id: 5 and current activity id= usertask2
Jan 04, 2017 1:21:40 PM java.util.logging.LogManager$RootLogger log
INFO: Task query count: 2
Jan 04, 2017 1:21:40 PM java.util.logging.LogManager$RootLogger log
INFO: Task query list size: 2

Hope this helps,


Thanks,

Thong Huynh