{"record":{"id":"62af916bcb6339ae","repo":"flowable/flowable-engine","slug":"there-are-count-decision-tables-with-key-d","errorCode":null,"errorMessage":"There are ${count} decision tables with key = '${decisionKey}' and version = '${decisionVersion}'.","messagePattern":"There are (.+?) decision tables with key = '(.+?)' and version = '(.+?)'\\.","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/persistence/entity/data/impl/MybatisDecisionDataManager.java","lineNumber":120,"sourceCode":"    @Override\n    public DecisionEntity findDecisionByDeploymentAndKeyAndTenantId(String deploymentId, String decisionKey, String tenantId) {\n        Map<String, Object> parameters = new HashMap<>();\n        parameters.put(\"deploymentId\", deploymentId);\n        parameters.put(\"decisionKey\", decisionKey);\n        parameters.put(\"tenantId\", tenantId);\n        return (DecisionEntity) getDbSqlSession().selectOne(\"selectDecisionByDeploymentAndKeyAndTenantId\", parameters);\n    }\n\n    @Override\n    public DecisionEntity findDecisionByKeyAndVersion(String decisionKey, Integer decisionVersion) {\n        Map<String, Object> params = new HashMap<>();\n        params.put(\"decisionKey\", decisionKey);\n        params.put(\"decisionVersion\", decisionVersion);\n        List<DecisionEntity> results = getDbSqlSession().selectList(\"selectDecisionsByKeyAndVersion\", params);\n        if (results.size() == 1) {\n            return results.get(0);\n        } else if (results.size() > 1) {\n            throw new FlowableException(\"There are \" + results.size() + \" decision tables with key = '\" + decisionKey + \"' and version = '\" + decisionVersion + \"'.\");\n        }\n        return null;\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public DecisionEntity findDecisionByKeyAndVersionAndTenantId(String decisionKey, Integer decisionVersion, String tenantId) {\n        Map<String, Object> params = new HashMap<>();\n        params.put(\"decisionKey\", decisionKey);\n        params.put(\"decisionVersion\", decisionVersion);\n        params.put(\"tenantId\", tenantId);\n        List<DecisionEntity> results = getDbSqlSession().selectList(\"selectDecisionsByKeyAndVersionAndTenantId\", params);\n        if (results.size() == 1) {\n            return results.get(0);\n        } else if (results.size() > 1) {\n            throw new FlowableException(\"There are \" + results.size() + \" decisions with key = '\" + decisionKey + \"' and version = '\" + decisionVersion + \"'.\");\n        }\n        return null;","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/persistence/entity/data/impl/MybatisDecisionDataManager.java#L102-L138","documentation":"Flowable's DMN engine found more than one row in ACT_DMN_DECISION with the same key and version when looking up a decision table via findDecisionByKeyAndVersion. The (KEY_, VERSION_) pair is expected to identify at most one deployed decision definition; duplicates indicate corrupted or manually duplicated deployment data. The engine throws FlowableException instead of guessing which definition to use.","triggerScenarios":"Calling findDecisionByKeyAndVersion (directly or through DMN rule/decision-table resolution APIs) when the DMN_DECISION table contains 2+ rows sharing the same KEY_ and VERSION_, e.g. after deploying the same decision table XML twice without redeploying (deployments with same resource forcing same version), manual DB copies, or imported data across environments.","commonSituations":"Database restored/merged from two environments with the same deployments; bulk import scripts that insert decision rows directly bypassing deployment versioning; deployment duplication caused by re-running deployment scripts with a fixed version label; multi-tenant data copied without tenant scoping (this variant has no tenant filter).","solutions":["Query the DB and remove/merge duplicate rows: SELECT * FROM ACT_DMN_DECISION WHERE KEY_ = '<key>' AND VERSION_ = <version>; delete the stale duplicates.","Redeploy the decision table cleanly: delete the duplicate deployments via the DMN repository API (DmnRepositoryService.deleteDeployment) so version management regenerates unique rows.","If duplicates are across tenants, switch to findDecisionByKeyAndVersionAndTenantId or set the tenant ID on the deployment so lookups are scoped.","Audit deployment scripts to ensure they do not force a fixed version or redeploy identical resources producing duplicate (key, version) rows."],"exampleFix":"// before: lookup fails due to duplicates\nDecisionEntity d = decisionEntityManager.findDecisionByKeyAndVersion(\"myTable\", 1);\n\n// after: scope by tenant / ensure unique version at deploy time\nDmnDeployment dep = dmnRepositoryService.createDeployment()\n    .tenantId(\"tenant-1\")\n    .addClasspathResource(\"diagrams/myTable.dmn\")\n    .deploy();\nDecisionEntity d = decisionEntityManager.findDecisionByKeyAndVersionAndTenantId(\"myTable\", 1, \"tenant-1\");","handlingStrategy":"validation","validationCode":"List<DecisionEntity> dupes = dmnManagementService // or direct SQL\n    .executeCommand(ctx -> ctx.getDbSqlSession().selectList(\"selectDecisionsByKeyAndVersion\",\n        Map.of(\"decisionKey\", key, \"decisionVersion\", version)));\nif (dupes == null || dupes.size() > 1) {\n    throw new IllegalStateException(\"Duplicate DMN decisions for \" + key + \" v\" + version + \": clean up ACT_DMN_DECISION before lookup\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    DecisionEntity d = dataManager.findDecisionByKeyAndVersion(key, version);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"There are\")) {\n        // run dedup/cleanup of duplicate ACT_DMN_DECISION rows, then retry\n    } else { throw e; }\n}","preventionTips":["Never insert directly into ACT_DMN_DECISION; always deploy via DmnRepositoryService so versions are managed.","Do not force fixed version numbers in deployment scripts.","Scope deployments and lookups with tenantId when running multi-tenant.","Add a unique-constraint/audit check on (KEY_, VERSION_, TENANT_ID_) in your DB migrations."],"tags":["flowable","dmn","database","duplicate-records"],"backgroundTag":"database-query-failed","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}