{"record":{"id":"37b2321b74f394bf","repo":"flowable/flowable-engine","slug":"this-method-is-not-supported-in-an-or-statement","errorCode":null,"errorMessage":"This method is not supported in an OR statement","messagePattern":"This method is not supported in an OR statement","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/ProcessInstanceQueryImpl.java","lineNumber":195,"sourceCode":"    public ProcessInstanceQuery processInstanceBusinessKey(String businessKey) {\n        if (businessKey == null) {\n            throw new FlowableIllegalArgumentException(\"Business key is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.businessKey = businessKey;\n        } else {\n            this.businessKey = businessKey;\n        }\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery processInstanceBusinessKey(String businessKey, String processDefinitionKey) {\n        if (businessKey == null) {\n            throw new FlowableIllegalArgumentException(\"Business key is null\");\n        }\n        if (inOrStatement) {\n            throw new FlowableIllegalArgumentException(\"This method is not supported in an OR statement\");\n        }\n\n        this.businessKey = businessKey;\n        this.processDefinitionKey = processDefinitionKey;\n        return this;\n    }\n\n    @Override\n    public ProcessInstanceQuery processInstanceBusinessKeyLike(String businessKeyLike) {\n        if (inOrStatement) {\n            this.currentOrQueryObject.businessKeyLike = businessKeyLike;\n        } else {\n            this.businessKeyLike = businessKeyLike;\n        }\n        return this;\n    }\n    \n    @Override","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/ProcessInstanceQueryImpl.java#L177-L213","documentation":"processInstanceBusinessKey(String, String) cannot be combined with or() query composition; Flowable throws FlowableIllegalArgumentException when it is called inside an or() block. Only the single-argument processInstanceBusinessKey variant supports OR statements. This is an API restriction on which criteria methods are valid within a disjunction.","triggerScenarios":"runtimeService.createProcessInstanceQuery().or().processInstanceBusinessKey(bk, pdk)... — calling the two-arg overload after or() and before endOr().","commonSituations":"Refactoring an existing query into an or() block without noticing the two-arg overload is excluded; generating queries dynamically where the criteria set lands inside an OR statement; misunderstanding that both overloads behave identically.","solutions":["Use the single-argument processInstanceBusinessKey(businessKey) inside the or() block and express the process definition constraint with processDefinitionKey(...) on the same or-operand scope if supported.","Move the combined businessKey+processDefinitionKey condition out of the or() block and AND it with the OR group instead.","Restructure the query into multiple queries and merge results in application code if the semantics require it."],"exampleFix":"// before\nquery.or().processInstanceBusinessKey(bk, pdk).processInstanceNameLike(name).endOr();\n// after\nquery.processDefinitionKey(pdk)\n    .or().processInstanceBusinessKey(bk).processInstanceNameLike(name).endOr();","handlingStrategy":"validation","validationCode":"boolean inOr = query instanceof ProcessInstanceQueryImpl\n        && ((ProcessInstanceQueryImpl) query).inOrStatement;\nif (inOr) {\n    throw new IllegalArgumentException(\"processInstanceBusinessKey(bk, pdk) is not allowed inside or(); use the single-arg overload\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    query.or().processInstanceBusinessKey(bk, pdk).endOr();\n} catch (FlowableIllegalArgumentException e) {\n    if (!e.getMessage().contains(\"not supported in an OR statement\")) throw e;\n    // rebuild using the single-argument overload inside the OR block\n}","preventionTips":["Use only the single-argument processInstanceBusinessKey inside or()/endOr() blocks.","Check the javadoc of each query criterion method for OR-statement support before refactoring into or().","Add a test for every query that uses or() to catch unsupported combinations early."],"tags":["flowable","query-api","or-statement","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}