mybatis/mybatis-3 · error · ExecutorException
Error getting nested result map values for
Error message
Error getting nested result map values for '{}'. Cause: {} What it means
A JDBC SQLException escaped while MyBatis read rows for a nested resultMap (an association or collection joined into the parent result). It is wrapped in an ExecutorException naming the property whose nested mapping failed, with the SQLException attached as cause. The mapping structure reached the JDBC layer; the driver then failed reading a value, so the real reason is in the cause.
Solutions
- Read the cause SQLException and fix what it points at (unknown column, cannot cast value, etc.).
- Check the nested resultMap's <result column="..."> names against the SELECT's actual (aliased) columns.
- Register or specify a TypeHandler for the nested property's Java/JDBC type combination.
- Reproduce the SELECT manually in a SQL client with the same aliases to confirm column names and types.
Defensive patterns
Strategy: try-catch
Try / catch
try {
return session.selectList("selectAuthorWithPosts");
} catch (PersistenceException e) {
if (e.getMessage() != null && e.getMessage().contains("nested result map values")) {
Throwable cause = e.getCause(); // SQLException with real driver reason
log.error("Nested mapping for property failed: {}", cause == null ? "?" : cause.getMessage());
}
throw e;
} Prevention
- Test nested resultMaps against the real schema in CI (column alias drift is the top cause).
- Register explicit TypeHandlers for exotic column types used in nested maps.
- Log the full cause chain in a central PersistenceException handler so driver details are never lost.
When it happens
Trigger: A resultMap with a nested <association>/<collection> resultMap; during getRowValue for the nested map a typeHandler.getResult(...) call throws SQLException — wrong column name, incompatible JDBC type conversion, exhausted stream, or driver-specific read error.
Common situations: Column alias typos in JOIN selects; missing typeHandler for an exotic column type inside a nested map; DB enum/json columns read with the wrong handler; driver cursor/streaming constraints on large nested result sets.
Related errors
- Error getting constructor collection nested result map…
- A query was run and no Result Maps were found for the…
- Ambiguous collection type for property
- ArrayType Handler requires SQL array or java array…
- Cannot add a collection result to non-collection based…
AI-assisted analysis of mybatis/mybatis-3@008069adb1 (2026-08-14).
Data as JSON: /api/errors/b5c123ec1c146830.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java:1434
linkObjects(metaObject, resultMapping, ancestorObject); // issue #385
}
continue;
}
}
final CacheKey rowKey = createRowKey(nestedResultMap, rsw, columnPrefix);
final CacheKey combinedKey = combineKeys(rowKey, parentRowKey);
Object rowValue = nestedResultObjects.get(combinedKey);
boolean knownValue = rowValue != null;
instantiateCollectionPropertyIfAppropriate(resultMapping, metaObject); // mandatory
if (anyNotNullColumnHasValue(resultMapping, columnPrefix, rsw)) {
rowValue = getRowValue(rsw, nestedResultMap, combinedKey, columnPrefix, rowValue);
if (rowValue != null && !knownValue) {
linkObjects(metaObject, resultMapping, rowValue);
foundValues = true;
}
}
} catch (SQLException e) {
throw new ExecutorException(
"Error getting nested result map values for '" + resultMapping.getProperty() + "'. Cause: " + e, e);
}
}
}
// (issue #101)
if (resultMap.hasResultMapsUsingConstructorCollection()) {
foundValues = applyNestedPendingConstructorCreations(rsw, resultMap, metaObject, parentPrefix, parentRowKey,
newObject, foundValues);
}
return foundValues;
}
private String getColumnPrefix(String parentPrefix, ResultMapping resultMapping) {
final StringBuilder columnPrefixBuilder = new StringBuilder();
if (parentPrefix != null) {
columnPrefixBuilder.append(parentPrefix);View on GitHub (pinned to 008069adb1)