{"record":{"id":"3f9180d2c0ee141d","repo":"mybatis/mybatis-3","slug":"name-does-not-contain-value-for-key","errorCode":null,"errorMessage":"name + \" does not contain value for \" + key","messagePattern":"name \\+ \" does not contain value for \" \\+ key","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/session/Configuration.java","lineNumber":1185,"sourceCode":"        }\n      }\n      return super.put(key, value);\n    }\n\n    @Override\n    public boolean containsKey(Object key) {\n      if (key == null) {\n        return false;\n      }\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 (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}\n","sourceCodeStart":1167,"sourceCodeEnd":1201,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/session/Configuration.java#L1167-L1201","documentation":"Configuration.StrictMap.get() throws IllegalArgumentException(name + \" does not contain value for \" + key) when a lookup by full statement name misses. In practice this is the classic \"Mapped Statements collection does not contain value for ...\" path's underlying mechanism: the runtime asked Configuration for a statement (or resultMap/sql fragment) whose fully-qualified name is not registered — wrong namespace, wrong id, or the mapper was never loaded.","triggerScenarios":"Calling sqlSession.selectOne(\"com.acme.UserMapper.findById\", ...) when the namespace is misspelled or the mapper XML is not registered; invoking a mapper interface method whose XML file is not in mapperLocations; namespace attribute not matching the interface's package-qualified name; interface bound via annotation but method has no @Select and no XML statement.","commonSituations":"Spring Boot mybatis.mapper-locations pattern missing a folder (classpath*: vs classpath:); renaming a package without updating XML namespaces; forgetting to add the <mapper> entry in mybatis-config.xml; method name in interface differs from XML statement id.","solutions":["Verify the exact string used to look up the statement against the XML namespace + id (or the interface's fully-qualified name + method name).","Confirm the mapper XML is actually loaded: check <mappers> in mybatis-config.xml or Spring mapperLocations pattern (prefer classpath*:com/acce/**/*Mapper.xml).","Align the XML namespace attribute with the mapper interface's fully-qualified name and the statement ids with method names.","Add an annotated statement (@Select etc.) or an XML statement for the missing method."],"exampleFix":"// before\nsqlSession.selectOne(\"com.acme.userMapper.findById\", 1);\n// after\nsqlSession.selectOne(\"com.acme.UserMapper.findById\", 1);  // matches namespace exactly","handlingStrategy":"validation","validationCode":"// Centralize statement names instead of string literals\npublic final class Stmts { public static final String FIND_BY_ID = UserMapper.class.getName() + \".findById\"; }\nConfiguration c = factory.getConfiguration();\nif (!c.hasStatement(Stmts.FIND_BY_ID)) throw new IllegalStateException(\"statement not registered: \" + Stmts.FIND_BY_ID);","typeGuard":null,"tryCatchPattern":"try { session.selectOne(name, param); }\ncatch (IllegalArgumentException e) { /* 'does not contain value for' -> typo or mapper not loaded */ throw e; }","preventionTips":["Build statement names from the mapper interface class (UserMapper.class.getName()) so renames propagate.","Verify mapperLocations patterns (use classpath*: for jars) at startup.","Prefer mapper interfaces (getMapper) over string-based lookups — compile-time method binding."],"tags":["mybatis","configuration","statement-not-found","namespace"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}