This endpoint:
/kie-server/services/rest/server/queries/processes/instances/variables/<VAR_NAME>?varValue=<VAR_VALUE>
Is using this named sql query - getProcessInstancesByVariableNameAndValue -
https://github.com/kiegroup/jbpm/blob/6.5.x/jbpm-services/jbpm-kie-services/src/main/resources/META-INF/Servicesorm.xml#L349
Due to the specific usage of 'max' aggregate function it functions only when one process variable is present in the given process instance.
Imagine following content of VariableInstanceLog table:
52 2017-08-01 10:15:50.589 MultiVars MultiVars.MultiVars 33 value1 var1 var1 53 2017-08-01 10:15:50.59 MultiVars MultiVars.MultiVars 33 value2 var2 var2
If you call this:
localhost:8280/kie-server/services/rest/server/queries/processes/instances/variables/var1?varValue=value1
It will return empty response, because the SQL query which has run behind the scene filtered variable with id '52' and only included id '53', so it's possible to successfully query var2 and not var1.
I managed to workaround this issue by replacing Servicesorm.xml file like this:
diff Servicesorm-old.xml Servicesorm-new.xml
349c349
< and vlog.id in (select max(vlog2.id) from VariableInstanceLog vlog2 group by vlog2.processInstanceId))
---
> and vlog.id in (select max(vlog2.id) from VariableInstanceLog vlog2 where vlog2.value like :variableValue and vlog2.variableId=:variable group by vlog2.processInstanceId))
Not submitting PR since there may be more effective way to fix this.
- is cloned by
-
RHBPMS-4845 [GSS](6.4.z) 'getProcessInstancesByVariableNameAndValue' does not work with multiple process variables
-
- Verified
-