Reputation: 5997
I'm looking for a solution to query completed tasks in Activiti by filtering on the completion date. Because once they're finished completed task entries are being moved into the act_hi_taskinst
table by the BPMN engine i would expected the required filters to be in the HistoricTaskInstanceQuery
class. However there's nothing like startedAfter
/startedBefore
and finishedAfter
/finishedBefore
methods like in the HistoricProcessInstanceQuery
. The table has the start_time_
and end_time_
columns so there's no reason why this kind of query would be not possible.
Is there an other way to filter by these properties or currently the only way to get around this is to query the act_hi_tasks
table directly bypassing the Activiti engine?
Upvotes: 2
Views: 2773
Reputation: 767
Activiti provides Query API so there is no need to query act_hi_taskinst
directly.
You query may look like this one
NativeHistoricTaskInstanceQuery taskQuery = historyService.createNativeHistoricTaskInstanceQuery();
taskQuery.sql("SELECT * FROM "+ managementService.getTableName(HistoricTaskInstance.class)+" WHERE start_time_=#{startTime} AND end_time_=#{endTime}");
taskQuery.parameter("startTime", startTime).parameter("endTime", end_time);
List<HistoricTaskInstance> tasks = taskQuery.list();
Upvotes: 5