{"record":{"id":"6aeb56212d2f1731","repo":"mybatis/mybatis-3","slug":"could-not-find-result-map-resultmapname-refere","errorCode":null,"errorMessage":"Could not find result map '{resultMapName}' referenced from '{statementId}'","messagePattern":"Could not find result map '(.+?)' referenced from '(.+?)'","errorType":"exception","errorClass":"IncompleteElementException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java","lineNumber":325,"sourceCode":"        throw new IncompleteElementException(\"Could not find parameter map \" + parameterMapName, e);\n      }\n    } else if (parameterTypeClass != null) {\n      parameterMap = ParameterMap.buildEmpty(statementId + \"-Inline\", parameterTypeClass);\n    }\n    return parameterMap;\n  }\n\n  private List<ResultMap> getStatementResultMaps(String resultMap, Class<?> resultType, String statementId) {\n    resultMap = applyCurrentNamespace(resultMap, true);\n\n    List<ResultMap> resultMaps = new ArrayList<>();\n    if (resultMap != null) {\n      String[] resultMapNames = resultMap.split(\",\");\n      for (String resultMapName : resultMapNames) {\n        try {\n          resultMaps.add(configuration.getResultMap(resultMapName.trim()));\n        } catch (IllegalArgumentException e) {\n          throw new IncompleteElementException(\n              \"Could not find result map '\" + resultMapName + \"' referenced from '\" + statementId + \"'\", e);\n        }\n      }\n    } else if (resultType != null) {\n      resultMaps.add(ResultMap.buildEmpty(configuration, statementId + \"-Inline\", resultType));\n    }\n    return resultMaps;\n  }\n\n  public ResultMapping buildResultMapping(Class<?> resultType, String property, String column, Class<?> javaType,\n      JdbcType jdbcType, String nestedSelect, String nestedResultMap, String notNullColumn, String columnPrefix,\n      Class<? extends TypeHandler<?>> typeHandler, List<ResultFlag> flags, String resultSet, String foreignColumn,\n      boolean lazy) {\n    Entry<Type, Class<?>> setterType = resolveSetterType(resultType, property, javaType);\n    TypeHandler<?> typeHandlerInstance = resolveTypeHandler(setterType.getKey(), jdbcType, typeHandler);\n    List<ResultMapping> composites;\n    if ((nestedSelect == null || nestedSelect.isEmpty()) && (foreignColumn == null || foreignColumn.isEmpty())) {\n      composites = List.of();","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java#L307-L343","documentation":"Thrown by getStatementResultMaps() when configuration.getResultMap() raises IllegalArgumentException for one of the comma-separated ids in a statement's resultMap attribute. It is an IncompleteElementException, so the statement is deferred and retried; it is fatal when the result map is genuinely missing.","triggerScenarios":"<select resultMap=\"userResult\"> where userResult is misspelled, defined in another (unregistered) mapper, or defined later and never resolved; also with multi-result-map lists like resultMap=\"a,b\" where any entry is missing.","commonSituations":"Typo in the resultMap id; referencing a result map in another namespace without the full namespace prefix; mapper XML file not included in mapperLocations; renaming a resultMap without updating statements; using an @ResultMap annotation value that does not exist.","solutions":["Check the resultMap id spelling and, for cross-mapper references, use the fully qualified name other.Mapper.resultMapId","Ensure the mapper file or interface defining the result map is actually loaded (mybatis-config.xml, mapperLocations pattern, package scan)","After refactors, search for references to the renamed/deleted result map"],"exampleFix":"<!-- before -->\n<select id=\"findUsers\" resultMap=\"userReslutMap\">\n<!-- after -->\n<select id=\"findUsers\" resultMap=\"userResultMap\">","handlingStrategy":"validation","validationCode":"// After building the Configuration, every statement's result maps are already resolved;\n// pre-build XML check for dangling references:\nfor (String stmtId : statementsUsingResultMapAttr()) {\n  for (String rmRef : resultMapRefsOf(stmtId)) {\n    String resolved = rmRef.contains(\".\") ? rmRef : namespace + \".\" + rmRef;\n    if (!definedResultMapIds.contains(resolved)) {\n      throw new IllegalStateException(stmtId + \" references unknown resultMap \" + rmRef);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  factory.getConfiguration().getMappedStatement(\"findUsers\");\n} catch (IllegalArgumentException e) {\n  // statement itself missing — usually caused by an unresolved resultMap during parse\n  throw new ConfigurationException(\"Statement failed to load; check resultMap refs: \" + e.getMessage(), e);\n}","preventionTips":["Use fully-qualified resultMap ids when referencing across mappers","Run mapper XML linting in CI (e.g. mybatis-generator validation or a custom SAX pass) to catch dangling refs","Keep resultMap ids stable or update references atomically in the same commit"],"tags":["mybatis","resultmap","statement","incomplete-element"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}