{"record":{"id":"4eb49a718aa4f1cd","repo":"flowable/flowable-engine","slug":"this-method-is-not-supported-in-an-or-statement-4eb49a","errorCode":null,"errorMessage":"This method is not supported in an OR statement","messagePattern":"This method is not supported in an OR statement","errorType":"exception","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java","lineNumber":145,"sourceCode":"    public ProcessInstanceQuery processInstanceBusinessKey(String businessKey) {\n        if (businessKey == null) {\n            throw new ActivitiIllegalArgumentException(\"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 ActivitiIllegalArgumentException(\"Business key is null\");\n        }\n        if (inOrStatement) {\n            throw new ActivitiIllegalArgumentException(\"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 processInstanceTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new ActivitiIllegalArgumentException(\"process instance tenant id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.tenantId = tenantId;\n        } else {\n            this.tenantId = tenantId;\n        }\n        return this;","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java#L127-L163","documentation":"Within an OR statement (query.or()...endOr()), only a subset of filter methods is supported. The two-argument processInstanceBusinessKey(businessKey, processDefinitionKey) throws ActivitiIllegalArgumentException('This method is not supported in an OR statement') because setting two fields at once breaks the single-criteria model of the OR block.","triggerScenarios":"Calling the two-argument overload between or() and endOr(), e.g. code that generically applies 'key + definition' filters and got refactored into an OR query for multi-criteria search.","commonSituations":"Advanced search forms that combine criteria with OR logic; copy-pasted query code moved into an or() block without checking the supported-methods list.","solutions":["Move the two-argument call outside the or()/endOr() block (combine with AND semantics)","Inside the OR block, use the single-argument processInstanceBusinessKey(businessKey) plus a separate processDefinitionKey() criterion only per supported OR rules","Restructure the search so OR-criteria use only allowed methods (e.g. businessKey, executionId, tenantId)","Catch ActivitiIllegalArgumentException during query construction in tests to catch unsupported combinations early"],"exampleFix":"// before\nquery.or()\n    .processInstanceBusinessKey(bk, defKey)      // not allowed in OR\n    .processInstanceTenantId(tenant)\n    .endOr();\n// after\nquery.processDefinitionKey(defKey);              // AND-level\nquery.or()\n    .processInstanceBusinessKey(bk)              // OR-safe overload\n    .processInstanceTenantId(tenant)\n    .endOr();","handlingStrategy":"try-catch","validationCode":"boolean inOr = false; // track via query state or code review\n// only call two-arg overload when NOT inside or()/endOr():\nquery.processInstanceBusinessKey(businessKey, processDefinitionKey); // AND scope only","typeGuard":"boolean orSafeFilter(java.util.function.Function<ProcessInstanceQuery,ProcessInstanceQuery> f) { return f != null; } // apply OR-safe methods only inside or() blocks","tryCatchPattern":"try {\n    query.or().processInstanceBusinessKey(bk, dk).endOr();\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"not supported in an OR statement\")) {\n        // restructure: apply two-arg filter outside OR, single-arg inside\n    }\n    throw e;\n}","preventionTips":["Restrict OR blocks to the documented supported methods (businessKey single-arg, executionId, tenantId, etc.)","Centralize OR-query building in one helper reviewed against the supported list","Write a test that builds every OR query combination the app uses","Use the single-argument overload inside OR and put definition-key narrowing at AND level"],"tags":["java","activiti","query","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"}