mybatis/mybatis-3 · error · ResultMapException
Error attempting to get column '" + columnName + "' from res
Error message
Error attempting to get column '" + columnName + "' from result set. Cause: " + e
What it means
BaseTypeHandler.getResult(rs, columnName) wraps every exception thrown while reading a column from the ResultSet via getNullableResult. The failure is either the driver reporting 'column not found' (SQL alias / resultMap mismatch) or a type conversion failure inside the concrete handler.
Source
Thrown at src/main/java/org/apache/ibatis/type/BaseTypeHandler.java:87
+ "Cause: " + e, e);
}
} else {
try {
setNonNullParameter(ps, i, parameter, jdbcType);
} catch (Exception e) {
throw new TypeException("Error setting non null for parameter #" + i + " with JdbcType " + jdbcType + " . "
+ "Try setting a different JdbcType for this parameter or a different configuration property. " + "Cause: "
+ e, e);
}
}
}
@Override
public T getResult(ResultSet rs, String columnName) throws SQLException {
try {
return getNullableResult(rs, columnName);
} catch (Exception e) {
throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set. Cause: " + e,
e);
}
}
@Override
public T getResult(ResultSet rs, int columnIndex) throws SQLException {
try {
return getNullableResult(rs, columnIndex);
} catch (Exception e) {
throw new ResultMapException("Error attempting to get column #" + columnIndex + " from result set. Cause: " + e,
e);
}
}
@Override
public T getResult(CallableStatement cs, int columnIndex) throws SQLException {
try {
return getNullableResult(cs, columnIndex);View on GitHub (pinned to 008069adb1)
Solutions
- Match the resultMap column attribute to the exact column label the query returns (add an SQL alias if needed)
- Check the Cause for a 'column not found' vs conversion error and fix the query or the property type accordingly
- For Oracle unquoted identifiers, use the upper-cased column name in the resultMap
Example fix
// before SELECT name AS userName ... <result column="name" property="userName"/> // after SELECT name AS userName ... <result column="userName" property="userName"/>
Defensive patterns
Strategy: try-catch
Validate before calling
// verify expected columns exist before mapping
ResultSetMetaData md = rs.getMetaData();
Set<String> cols = new HashSet<>();
for (int i = 1; i <= md.getColumnCount(); i++) cols.add(md.getColumnLabel(i).toUpperCase());
if (!cols.contains("USERNAME")) throw new IllegalStateException("column USERNAME missing"); Try / catch
try { ... } catch (ResultMapException e) { // e names the column; compare with the SELECT's aliases and fix the resultMap } Prevention
- Always alias computed/renamed columns in SELECT and reference the same alias in resultMap
- Integration-test every resultMap against the real query
- Beware identifier casing per database (Oracle upper-case) — use consistent aliases
When it happens
Trigger: A resultMap or auto-mapping references a column name that the SELECT does not return (missing alias, typo, column removed from query); or the handler mapped for the property cannot convert the column value (e.g. reading a non-numeric string as Integer).
Common situations: Changing the SELECT list without updating the resultMap; DB views/queries whose column casing differs (Oracle upper-cases unquoted identifiers); handler mismatch after changing a property type.
Related errors
- Could not find a parent resultMap with id '{extend}'
- Could not find result map '{resultMapName}' referenced from
- Error in result map '{resultMapId}'. Failed to find a constr
- Error in result map '{resultMapId}'. We do not support parti
- If there is no type discriminator, then the NamedResultMap a
AI-assisted analysis of mybatis/mybatis-3@008069adb1 (2026-08-14).
Data as JSON: /api/errors/b24ed27fc89c215c.
Report an issue: GitHub.