12-28-2016 01:17 AM
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.
12-29-2016 10:24 AM
01-04-2017 01:30 AM
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
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
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.