ProcessInstanceQuery・HistoricProcessInstanceQuery's queryVariableValues should be used to target only the global scope variables?
See original GitHub issueProcessInstanceQuery・HistoricProcessInstanceQuery’s queryVariableValues should be used to target only the global scope variables? Which is correct, the specifications of javadoc or the actual source code?
Correct behavior
We think ProcessInstanceQuery・HistoricProcessInstanceQuery’s queryVariableValues should be used to target only the global scope variables. This specification is written in the following javadoc.
- http://activiti.org/javadocs/org/activiti/engine/runtime/ProcessInstanceQuery.html#variableValueEquals(java.lang.Object)
- http://activiti.org/javadocs/org/activiti/engine/history/HistoricProcessInstanceQuery.html#variableValueEquals(java.lang.Object)
And, because ProcessInstanceQuery・HistoricProcessInstanceQuery’s return only the global scope variables(includeProcessVariables flag), the search criteria specification also should target only the global scope variables.
Actual behavior
But, ProcessInstanceQuery・HistoricProcessInstanceQuery’s queryVariableValues can be used to target the execution scope and task scope variables,too.
<foreach collection="queryVariableValues" index="index" item="queryVariableValue">
inner join ${prefix}ACT_HI_VARINST A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_
</foreach>
We thought this behavior was bug,but the test case(HistoryServiceTest.testHistoricVariableInstancesOnParallelExecution) guarantees this behavior.
List<Task> tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).list();
for (Task task : tasks) {
Map<String, Object> variables = new HashMap<String, Object>();
// set token local variable
log.debug("setting variables on task {}, execution {}", task.getId(), task.getExecutionId());
runtimeService.setVariableLocal(task.getExecutionId(), "parallelValue1", task.getName());
runtimeService.setVariableLocal(task.getExecutionId(), "parallelValue2", "test");
taskService.complete(task.getId(), variables);
}
taskService.complete(taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult().getId());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("rootValue", "test").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue1", "Receive Payment").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue1", "Ship Order").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue2", "test").count());
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
I see and understand your point. It’s indeed not consistent. But I’m also weary of breaking code for users that currently depend on the inconsistent behavior.
What concrete use case are you trying to fix with this?
I’m closing this due to inactivity for more than a year. Please reopen if this is an issue.