mybatis/mybatis-3 · error · IncompleteElementException

Could not find result map '{resultMapName}' referenced from

Error message

Could not find result map '{resultMapName}' referenced from '{statementId}'

What it means

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.

Source

Thrown at src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java:325

        throw new IncompleteElementException("Could not find parameter map " + parameterMapName, e);
      }
    } else if (parameterTypeClass != null) {
      parameterMap = ParameterMap.buildEmpty(statementId + "-Inline", parameterTypeClass);
    }
    return parameterMap;
  }

  private List<ResultMap> getStatementResultMaps(String resultMap, Class<?> resultType, String statementId) {
    resultMap = applyCurrentNamespace(resultMap, true);

    List<ResultMap> resultMaps = new ArrayList<>();
    if (resultMap != null) {
      String[] resultMapNames = resultMap.split(",");
      for (String resultMapName : resultMapNames) {
        try {
          resultMaps.add(configuration.getResultMap(resultMapName.trim()));
        } catch (IllegalArgumentException e) {
          throw new IncompleteElementException(
              "Could not find result map '" + resultMapName + "' referenced from '" + statementId + "'", e);
        }
      }
    } else if (resultType != null) {
      resultMaps.add(ResultMap.buildEmpty(configuration, statementId + "-Inline", resultType));
    }
    return resultMaps;
  }

  public ResultMapping buildResultMapping(Class<?> resultType, String property, String column, Class<?> javaType,
      JdbcType jdbcType, String nestedSelect, String nestedResultMap, String notNullColumn, String columnPrefix,
      Class<? extends TypeHandler<?>> typeHandler, List<ResultFlag> flags, String resultSet, String foreignColumn,
      boolean lazy) {
    Entry<Type, Class<?>> setterType = resolveSetterType(resultType, property, javaType);
    TypeHandler<?> typeHandlerInstance = resolveTypeHandler(setterType.getKey(), jdbcType, typeHandler);
    List<ResultMapping> composites;
    if ((nestedSelect == null || nestedSelect.isEmpty()) && (foreignColumn == null || foreignColumn.isEmpty())) {
      composites = List.of();

View on GitHub (pinned to 008069adb1)

Solutions

  1. Check the resultMap id spelling and, for cross-mapper references, use the fully qualified name other.Mapper.resultMapId
  2. Ensure the mapper file or interface defining the result map is actually loaded (mybatis-config.xml, mapperLocations pattern, package scan)
  3. After refactors, search for references to the renamed/deleted result map

Example fix

<!-- before -->
<select id="findUsers" resultMap="userReslutMap">
<!-- after -->
<select id="findUsers" resultMap="userResultMap">
Defensive patterns

Strategy: validation

Validate before calling

// After building the Configuration, every statement's result maps are already resolved;
// pre-build XML check for dangling references:
for (String stmtId : statementsUsingResultMapAttr()) {
  for (String rmRef : resultMapRefsOf(stmtId)) {
    String resolved = rmRef.contains(".") ? rmRef : namespace + "." + rmRef;
    if (!definedResultMapIds.contains(resolved)) {
      throw new IllegalStateException(stmtId + " references unknown resultMap " + rmRef);
    }
  }
}

Try / catch

try {
  factory.getConfiguration().getMappedStatement("findUsers");
} catch (IllegalArgumentException e) {
  // statement itself missing — usually caused by an unresolved resultMap during parse
  throw new ConfigurationException("Statement failed to load; check resultMap refs: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: <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.

Common situations: 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.

Related errors


AI-assisted analysis of mybatis/mybatis-3@008069adb1 (2026-08-14). Data as JSON: /api/errors/6aeb56212d2f1731. Report an issue: GitHub.