cancel
Showing results for 
Search instead for 
Did you mean: 

HistoricProcessInstanceQuery interface finished() method

pault
Star Contributor
Star Contributor
I dont seem to be able to get this to work, it always seems to report 0. Or maybe I'm missing something ?

This code :

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

Produces this output :

                Total Historic Processes = 7
                 Processes in progress = 2
                 Processes completed = 0

The database looks like this :

SELECT * FROM ACT_HI_PROCINST;
ID_     PROC_INST_ID_     BUSINESS_KEY_     PROC_DEF_ID_     START_TIME_     END_TIME_     DURATION_     START_USER_ID_     START_ACT_ID_     END_ACT_ID_ 
3   3   null   financialReport:1   2010-12-10 10:39:06.131   2010-12-10 10:39:12.4   6269   null   theStart   theEnd
8   8   null   financialReport:1   2010-12-10 10:39:12.46   2010-12-10 10:39:24.577   12117   null   theStart   theEnd
13   13   null   financialReport:1   2010-12-10 10:39:18.479   2010-12-10 10:39:24.667   6188   null   theStart   theEnd
18   18   null   financialReport:1   2010-12-10 10:39:24.718   2010-12-10 10:39:36.885   12167   null   theStart   theEnd
23   23   null   financialReport:1   2010-12-10 10:39:30.736   2010-12-10 10:39:36.945   6209   null   theStart   theEnd
28   28   null   financialReport:1   2010-12-10 10:39:36.975   null   null   null   theStart   null
33   33   null   financialReport:1   2010-12-10 10:39:43.004   null   null   null   theStart   null
(7 rows, 10 ms)
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
As I mentioned in http://forums.activiti.org/en/viewtopic.php?f=3&t=593, the Query instances in our query API are statefull (they keep the unfinished() etc. internally).

Ask new query-instances from the HistoryService, for each different query you want to perform. Offcourse, this doesn't mean that query instances cannot be reused.

pault
Star Contributor
Star Contributor
Thanks, I understand - should have realised, but it works fine now.

frederikherema1
Star Contributor
Star Contributor
Glad to be of service. Enjoy activiti!