cancel
Showing results for 
Search instead for 
Did you mean: 

More on HistoricProcessInstanceQuery issue

pault
Star Contributor
Star Contributor
It seems to be not as simple as just the finished() method not working. The results seem to depend on what was called previouslly - or I really am missing something obvious here.

The code :

      System.out.println("Total Historic Processes = "+piHistory.count());
      System.out.println("Processes in progress = "+piHistory.unfinished().count());
      System.out.println("Total Historic Processes = "+piHistory.count());

Produces the following output :

                Total Historic Processes = 2
                Processes in progress = 1
                Total Historic Processes = 1

I would not expect the total number of historic processes ever to go down ?
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
Paul… I see you are re-using the object instance 'piHistory' tree times. When you use "unfinished", the query instance will ALWAYS return the unfinished processes, in other words, the HistoricProcessQuery (and all queries in our API) are statefull.

What you want do do, should look like this:


System.out.println("Total Historic Processes = "+historyService.createHistoricProcessInstanceQuery().count());
System.out.println("Processes in progress = "+historyService.createHistoricProcessInstanceQuery().unfinished().count());
System.out.println("Total Historic Processes = "+historyService.createHistoricProcessInstanceQuery().count());