I have this piece of code :
List<ProcessInstance> instances =
processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).list();
instances.forEach(this::listProcessInstance);
private void listProcessInstance (ProcessInstance processInstance) {
log.info("<-------------- ProcessInstance ---------------> {} ", processInstance);
log.info(String.valueOf(processInstance.getProcessVariables()));
log.info("<-------------- ProcessInstance --------------->");
}
where ProcessVariables is null, but going on the tabla there are info:
select * from ACT_RU_VARIABLE where PROC_INST_ID_ = 76759;
For performance reasons the default query does not return the process variables. You have to explicitly tell the query to include the variables:
List<ProcessInstance> instances = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().list();