Problem with the task query and or clause

Hello everyone,

I’m on a Spring Boot 3.4 with Flowable open source 7.1.0

I’m working on a simple project. And we have a parent case, that goes into sub processes. I’m trying to fetch in Java the list of task for the parent case, and all of its processes. For this I’m using TaskService. In parameter I have the caseInstanceId.

What I’ve done to fetch this is that Java query:

taskService.createTaskQuery().or().caseInstanceId(activityFlowQuery.getProjectId());

var planItems = cmmnRuntimeService.createPlanItemInstanceQuery().caseInstanceId(activityFlowQuery.getProjectId()).planItemInstanceStateActive().onlyStages().list();

if (!planItems.isEmpty()) {
    for (var planItem : planItems) {
        query = query.propagatedStageInstanceId(planItem.getId());
    }
}

Basically to summarize the goal of the code: give me all task which are directly from that caseInstanceId or with a propagatedStageId which matches any active stage from the caseInstanceId.

To test I have 1 case instance, with no direct active task, and a task in a direct subprocess. And another case instance with a direct active task, which I will not test on, but it’s there.

But it’s returning me tasks from other case instances… So I tried to simplify my code, maybe I was not using the right conditions. So I simplified my code:

  • Just with the caseInstanceId → Return nothing, OK
  • Just with the processInstanceId → return one task, OK
  • With both and a or close → return 2 tasks, one is expected but the second has nothing to do here, no process instance neither case instance matches. NOK

code: taskService.createTaskQuery().or().caseInstanceId("6d08543e-d737-11ef-900c-ca6e9169e3e9").processInstanceId("ada12757-d7ca-11ef-95fa-ca6e9169e3e9").endOr().list()

basically: caseInstanceId | processInstanceId. From the Java doc, it seems the or() and endOrneed to surround my parameters. I thought maybe starting by a .or() was causing issue, so I added an .active(). But that did nothing.

am I misunderstanding something? Is there a simpler way to do this?

Thanks in advance

EDIT: I activated the log and checked the SQL Query it generated.

For this code:

taskService.createTaskQuery().active().or().caseInstanceId("6d08543e-d737-11ef-900c-ca6e9169e3e9").processInstanceId("ada12757-d7ca-11ef-95fa-ca6e9169e3e9").endOr()orderByDueDateNullsLast().asc()

It generated: SELECT RES.* from ACT_RU_TASK RES WHERE RES.SUSPENSION_STATE_ = 1 and ( RES.PROC_INST_ID_ = ? or RES.SCOPE_ID_ = ? or RES.SCOPE_TYPE_ = ? ) order by RES.DUE_DATE_ asc NULLS LAST

It seems there is a bug. Adding the case Instance Id add (scopd_id_ = ? or scop_type_ = ?) . which looks correct by itself but when combined with another or clause gives all CMMN tasks