cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with listPage when using HistoricProcessInstanceQuery

emartinez
Champ in-the-making
Champ in-the-making
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()
                  .includeProcessVariables()
                  .variableValueEquals("estado", estado).list();//.listPage(offset, limit);
            if(hProcess != null && hProcess.size() > 0) {
               for(HistoricProcessInstance hInst : hProcess) {
                  //System.out.println((String)hInst.getProcessVariables().get("variable"));
                  list.add((String)hInst.getProcessVariables().get("variable"));
               }
            }
            // 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.
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
Hmm this sounds like a bug indeed. Any chance you can show it in a simplified unit test … it's hard to reproduce without the context?