AnsweredAssumed Answered

Problem with listPage when using HistoricProcessInstanceQuery

Question asked by emartinez on Apr 14, 2014
Latest reply on Apr 22, 2014 by jbarrez
Hi, this is my first post in this forum.

I have this code :

                List<String> estados = new ArrayList<String>();
                estados.add("Status 1");
                estados.add("Status 2"); // etc
      List<String> list = new ArrayList<String>();
      HistoricProcessInstanceQuery hQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process_pool1");
      if(hQuery != null) {
         for(String estado : estados) {
            List<HistoricProcessInstance> hProcess = hQuery.finished()
                  .variableValueEquals("estado", estado).list();//.listPage(offset, limit);
            if(hProcess != null && hProcess.size() > 0) {
               for(HistoricProcessInstance hInst : hProcess) {
            // Reinstante it or it won't work…
            hQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process_pool1");

The problem is in the next line

.variableValueEquals("estado", estado).list();//.listPage(offset, limit);

I have two finished tasks with the status "Status 1".

If I try
listPage(0, 10)
it returns nothing.
If I try
listPage(10, 10)
it returns nothing.
if I try
listPage(20, 10)
it returns one of the two records…

The thing is simple, there's something wrong with that method, or I don't know how to use it. If I have two records with those conditions, then the first listPage (0, 10) should return them, but it doesn't. For now I'm using list() to return them all, but I need to use it in a pagination, but it's not working. If I search in ACT_HI_VARINST for NAME_='estado' AND TEXT_='Status 1' I get the two records.

I'm using activiti 5.13

Thanks in advance. I can't post more code, this is from my work.