{"record":{"id":"8004b28d336e3007","repo":"mybatis/mybatis-3","slug":"could-not-process-result-for-mapping-construc","errorCode":null,"errorMessage":"Could not process result for mapping: \" + constructorMapping","messagePattern":"Could not process result for mapping: \" \\+ constructorMapping","errorType":"exception","errorClass":"ExecutorException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java","lineNumber":831,"sourceCode":"            value = collection.getOriginalObject();\n          } else {\n            value = toSingleObj(result);\n          }\n        } else if (constructorMapping.getNestedResultMapId() != null) {\n          final String constructorColumnPrefix = getColumnPrefix(columnPrefix, constructorMapping);\n          final ResultMap resultMap = resolveDiscriminatedResultMap(rsw,\n              configuration.getResultMap(constructorMapping.getNestedResultMapId()), constructorColumnPrefix);\n          value = getRowValue(rsw, resultMap, constructorColumnPrefix,\n              useCollectionConstructorInjection ? parentRowKey : null);\n        } else {\n          TypeHandler<?> typeHandler = constructorMapping.getTypeHandler();\n          if (typeHandler == null) {\n            typeHandler = typeHandlerRegistry.getTypeHandler(constructorMapping.getJavaType(), rsw.getJdbcType(column));\n          }\n          value = typeHandler.getResult(rsw.getResultSet(), prependPrefix(column, columnPrefix));\n        }\n      } catch (ResultMapException | SQLException e) {\n        throw new ExecutorException(\"Could not process result for mapping: \" + constructorMapping, e);\n      }\n\n      constructorArgTypes.add(parameterType);\n      constructorArgs.add(value);\n\n      foundValues = value != null || foundValues;\n    }\n\n    if (!foundValues) {\n      return null;\n    }\n\n    if (useCollectionConstructorInjection) {\n      // at least one of the nestedResultMaps contained a collection, we have to defer until later\n      return new PendingConstructorCreation(resultType, constructorArgTypes, constructorArgs);\n    }\n\n    return objectFactory.create(resultType, constructorArgTypes, constructorArgs);","sourceCodeStart":813,"sourceCodeEnd":849,"githubUrl":"https://github.com/mybatis/mybatis-3/blob/008069adb1b089579b5dcba87ee591908b263274/src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java#L813-L849","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"<!-- before -->\n<constructor>\n  <arg column=\"usr_name\" javaType=\"string\"/>  <!-- column is actually user_name -->\n</constructor>\n<!-- after -->\n<constructor>\n  <arg column=\"user_name\" javaType=\"string\"/>\n</constructor>","handlingStrategy":"try-catch","validationCode":"// Keep <arg column> names in sync with the SELECT aliases: assert at test time\ntry (SqlSession s = factory.openSession()) {\n  s.selectList(\"sel.usersCtor\"); // integration test exercising every constructor-mapped statement\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["mybatis","constructor-mapping","typehandler","column-mapping"],"backgroundTag":null,"analyzedSha":"008069adb1b089579b5dcba87ee591908b263274","analyzedAt":"2026-08-14T13:07:10.264Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}