AnsweredAssumed Answered

ProcessInstanceQuery and runtime performance

Question asked by kermit on Oct 20, 2011
Latest reply on Oct 21, 2011 by trademak

I defined a process that performs different tasks. During the execution of the process it evaluates new variables.
I have to show a web page with the list of processes that satisfy a certain condition on one of the variables.

I have successfully run a ProcessInstanceQuery().list() method with a filter on that variable
That method  returns a list of ProcessInstance.
However the single element in the list contains only the id of the process instead I also need the value of a variable of the process.

I tried to cast the ProcessInstance to ExecutionEntity  and use the method getVariabile("my var") but I get a "lazy loading outside commandContext" error.

The only alternative seems to loop on the list of results and execute a runtimeService.getVariable("my var") for each element.

Is there a better way to do this in a efficient way (not too many sql queries requests)?

best regards