mybatis/mybatis-3 · error · ExecutorException
Could not process result for mapping: " + constructorMapping
Error message
Could not process result for mapping: " + constructorMapping
What it means
While building a constructor-arg value for constructor-based result mapping, either the nested-row load (getRowValue for a nested resultMap arg) or the TypeHandler read (typeHandler.getResult on the column) threw SQLException/ResultMapException. MyBatis wraps it with the offending constructorMapping printed, so you can see exactly which <arg> failed.
Source
Thrown at src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java:831
value = collection.getOriginalObject();
} else {
value = toSingleObj(result);
}
} else if (constructorMapping.getNestedResultMapId() != null) {
final String constructorColumnPrefix = getColumnPrefix(columnPrefix, constructorMapping);
final ResultMap resultMap = resolveDiscriminatedResultMap(rsw,
configuration.getResultMap(constructorMapping.getNestedResultMapId()), constructorColumnPrefix);
value = getRowValue(rsw, resultMap, constructorColumnPrefix,
useCollectionConstructorInjection ? parentRowKey : null);
} else {
TypeHandler<?> typeHandler = constructorMapping.getTypeHandler();
if (typeHandler == null) {
typeHandler = typeHandlerRegistry.getTypeHandler(constructorMapping.getJavaType(), rsw.getJdbcType(column));
}
value = typeHandler.getResult(rsw.getResultSet(), prependPrefix(column, columnPrefix));
}
} catch (ResultMapException | SQLException e) {
throw new ExecutorException("Could not process result for mapping: " + constructorMapping, e);
}
constructorArgTypes.add(parameterType);
constructorArgs.add(value);
foundValues = value != null || foundValues;
}
if (!foundValues) {
return null;
}
if (useCollectionConstructorInjection) {
// at least one of the nestedResultMaps contained a collection, we have to defer until later
return new PendingConstructorCreation(resultType, constructorArgTypes, constructorArgs);
}
return objectFactory.create(resultType, constructorArgTypes, constructorArgs);View on GitHub (pinned to 008069adb1)
Solutions
- Inspect the printed constructorMapping and the cause exception: fix the named column (typo, missing alias, columnPrefix) or the javaType
- Pin an explicit typeHandler on the <arg> if the default lookup picks the wrong one
- Keep result column aliases in the SELECT in sync with the <arg column=...> names
Example fix
<!-- before --> <constructor> <arg column="usr_name" javaType="string"/> <!-- column is actually user_name --> </constructor> <!-- after --> <constructor> <arg column="user_name" javaType="string"/> </constructor>
Defensive patterns
Strategy: try-catch
Validate before calling
// Keep <arg column> names in sync with the SELECT aliases: assert at test time
try (SqlSession s = factory.openSession()) {
s.selectList("sel.usersCtor"); // integration test exercising every constructor-mapped statement
} Try / catch
catch (ExecutorException e) { if (e.getMessage() != null && e.getMessage().contains("Could not process result for mapping")) { log.error("Failing mapping: {}", e.getMessage(), e.getCause()); } throw e; } Prevention
- Column aliases in SQL must exactly match <arg column> values
- Specify javaType and typeHandler explicitly on constructor args for non-obvious columns
- Run a row-fetch smoke test per resultMap in CI
When it happens
Trigger: createParameterizedResultObject processes a <constructor><arg> whose column has no readable value, whose typeHandler is unresolved/mismatched, or whose nested resultMap fails — the catch on ResultMapException | SQLException converts it to this ExecutorException with the mapping as context.
Common situations: Constructor arg column name typo so rs.getXxx fails; jdbcType/javaType mismatch in the constructor arg (e.g. mapping a VARCHAR to int); nested collection constructor args hitting their own mapping errors; stored procs returning fewer columns than mapped after schema change.
Related errors
- Error in result map '{resultMapId}'. Failed to find a constr
- Error in result map '{resultMapId}'. We do not support parti
- Expected result object to be a pending constructor creation!
- No type handler found for '" + javaType + "' and JDBC type '
- Do not know how to create an instance of " + resultType
AI-assisted analysis of mybatis/mybatis-3@008069adb1 (2026-08-14).
Data as JSON: /api/errors/8004b28d336e3007.
Report an issue: GitHub.