mybatis/mybatis-3 · error · ExecutorException
Error getting constructor collection nested result map value
Error message
Error getting constructor collection nested result map values for '" + constructorMapping.getProperty() + "'. Cause: " + e
What it means
A JDBC SQLException escaped while MyBatis was reading column values to build a nested (collection) result that feeds a constructor argument. MyBatis wraps it in an ExecutorException naming the constructor mapping property, preserving the original SQLException as the cause. The root cause is nearly always the underlying JDBC problem (bad column name/type read, closed cursor), not the mapping topology itself.
Source
Thrown at src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java:1340
continue;
}
if (rowValue instanceof PendingConstructorCreation) {
if (newValueForNestedResultMap) {
// we created a brand new pcc. this is a new collection value
pendingConstructorCreation.linkCreation(constructorMapping, (PendingConstructorCreation) rowValue);
foundValues = true;
}
} else {
pendingConstructorCreation.linkCollectionValue(constructorMapping, rowValue);
foundValues = true;
if (combinedKey != CacheKey.NULL_CACHE_KEY) {
nestedResultObjects.put(combinedKey, pendingConstructorCreation);
}
}
} catch (SQLException e) {
throw new ExecutorException("Error getting constructor collection nested result map values for '"
+ constructorMapping.getProperty() + "'. Cause: " + e, e);
}
}
return foundValues;
}
private void createPendingConstructorCreations(Object rowValue) {
// handle possible pending creations within this object
// by now, the property mapping has been completely built, we can reconstruct it
final PendingRelation pendingRelation = pendingPccRelations.remove(rowValue);
final MetaObject metaObject = pendingRelation.metaObject;
final ResultMapping resultMapping = pendingRelation.propertyMapping;
// get the list to be built
Object collectionProperty = instantiateCollectionPropertyIfAppropriate(resultMapping, metaObject);
if (collectionProperty != null) {
// we expect pending creations nowView on GitHub (pinned to 008069adb1)
Solutions
- Inspect the wrapped cause (SQLException) — fix the actual JDBC-level problem it names (unknown column, type mismatch, closed result set).
- Verify the nested collection's resultMap column names/types match the actual result set columns.
- Verify a suitable TypeHandler is registered for the nested element Java type / JDBC type combination.
- If using multiple result sets with constructor collections, restructure to a single result set or move the collection to a setter mapping — that combination is explicitly unsupported (separate error).
Defensive patterns
Strategy: try-catch
Try / catch
try {
List<Order> orders = session.selectList("selectOrdersWithItems");
} catch (PersistenceException e) {
Throwable root = Stream.iterate(e, Throwable::getCause)
.takeWhile(Objects::nonNull).reduce((a, r) -> r).orElse(e);
if (root instanceof SQLException sqlEx
&& e.getMessage().contains("constructor collection nested result map")) {
// driver-level failure while reading nested rows: surface column/type info
log.error("Nested constructor collection read failed: sqlState={}, msg={}",
sqlEx.getSQLState(), sqlEx.getMessage());
}
throw e;
} Prevention
- Always log the cause chain; the actionable detail is in the SQLException, not the wrapper.
- Smoke-test nested constructor-collection maps against the real DB in CI so column/type mismatches surface before production.
- Keep nested resultMap column names in sync with SELECT aliases via a shared constants file or codegen.
When it happens
Trigger: A resultMap with <constructor> containing a <collection> (collection mapped into a constructor argument via nested result maps); while reading rows for the nested collection the driver throws SQLException — e.g. type handler calls resultSet.getXxx with a column absent from the nested query, an incompatible type conversion, or cursor/streaming limits.
Common situations: Mapping collections into immutable objects via constructor collection mappings; column name typos in nested select columns; DB type mismatches (e.g. reading a VARCHAR column as an INT handler); driver limitations on open result sets with multiple result sets (see sibling limitation error 'Cannot construct objects with collections in constructors using multiple result sets yet!').
Related errors
- Expected result object to be a pending constructor creation!
- Cannot construct objects with collections in constructors us
- Cannot reliably construct result if we are not sure the resu
- Error getting nested result map values for '{}'. Cause: {}
- Cannot add a collection result to non-collection based resul
AI-assisted analysis of mybatis/mybatis-3@008069adb1 (2026-08-14).
Data as JSON: /api/errors/acebcaaa439fbe7b.
Report an issue: GitHub.