{"record":{"id":"0102188663d1e8a5","repo":"baomidou/mybatis-plus","slug":"s-is-ambiguous-in-s-try-using-the-full-name-inc","errorCode":null,"errorMessage":"%s is ambiguous in %s (try using the full name including the namespace, or rename one of the entries)","messagePattern":"(.+?) is ambiguous in (.+?) \\(try using the full name including the namespace, or rename one of the entries\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisConfiguration.java","lineNumber":485,"sourceCode":"            return super.put(key, value);\n        }\n\n        @Override\n        public boolean containsKey(Object key) {\n            if (key == null) {\n                return false;\n            }\n            return super.get(key) != null;\n        }\n\n        @Override\n        public V get(Object key) {\n            V value = super.get(key);\n            if (value == null) {\n                throw new IllegalArgumentException(name + \" does not contain value for \" + key);\n            }\n            if (useGeneratedShortKey && AMBIGUITY_INSTANCE == value) {\n                throw new IllegalArgumentException(key + \" is ambiguous in \" + name\n                    + \" (try using the full name including the namespace, or rename one of the entries)\");\n            }\n            return value;\n        }\n\n        private String getShortName(String key) {\n            final String[] keyParts = key.split(\"\\\\.\");\n            return keyParts[keyParts.length - 1];\n        }\n    }\n}\n","sourceCodeStart":467,"sourceCodeEnd":497,"githubUrl":"https://github.com/baomidou/mybatis-plus/blob/bf67d907478c724120bf76292da54abf9e73c2b3/mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/MybatisConfiguration.java#L467-L497","documentation":"Thrown by StrictMap.get when the value stored under a short key is the AMBIGUITY_INSTANCE sentinel. When useGeneratedShortKey is enabled, StrictMap stores a short name (text after the last dot) for each fully-qualified key; if two different full keys collapse to the same short name, the sentinel replaces the value and any later lookup by the short name throws this ambiguity error.","triggerScenarios":"Two mapped statements whose fully-qualified ids differ only in namespace but share the same trailing segment (e.g. com.a.UserMapper.selectById and com.b.UserMapper.selectById), then referencing the statement by its short name 'selectById'.","commonSituations":"Multiple modules each with a mapper containing identically-named statements; CRUD BaseMapper methods generating identical short ids across many mapper namespaces while some code path resolves by short name; copying mapper XML between modules without renaming ids.","solutions":["Always reference statements by their full name including the namespace (e.g. com.example.UserMapper.selectById) instead of the short name, as the message suggests.","Rename one of the colliding statement ids so short names are unique.","Audit the error message key: it names the ambiguous short key; find all namespaces providing it and disambiguate callers."],"exampleFix":"// before\nList<User> users = sqlSession.selectList(\"selectById\", 1);\n\n// after\nList<User> users = sqlSession.selectList(\"com.example.UserMapper.selectById\", 1);","handlingStrategy":"validation","validationCode":"// detect ambiguous short keys before use\nclass ShortKeyScan {\n    static Set<String> ambiguous(Collection<String> ids) {\n        Map<String, Integer> counts = new HashMap<>();\n        ids.forEach(i -> counts.merge(i.substring(i.lastIndexOf('.') + 1), 1, Integer::sum));\n        return counts.entrySet().stream().filter(e -> e.getValue() > 1)\n            .map(Map.Entry::getKey).collect(java.util.stream.Collectors.toSet());\n    }\n}","typeGuard":null,"tryCatchPattern":"Catch IllegalArgumentException matching \"is ambiguous in\"; extract the short key and switch the caller to the fully-qualified statement name.","preventionTips":["Always reference statements with the full namespace-qualified id.","Give multi-module mapper statements distinct ids, not just distinct namespaces."],"tags":["mybatis","mybatis-plus","ambiguous-key","configuration","namespace"],"backgroundTag":null,"analyzedSha":"bf67d907478c724120bf76292da54abf9e73c2b3","analyzedAt":"2026-08-14T15:17:09.543Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}