- Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Description
there are two table with the same column name 'ID' and without the same type
<resultMap id="BaseResultMap" type="com.geco.domain.MdProduct"> <id column="ID" property="id" jdbcType="VARCHAR" /> ... </resultMap> <resultMap id="InfoResultMap" extends="BaseResultMap" type="com.geco.service.product.dto.ProductResp"> <result column="INFO_ID" property="additionalInfo.id" jdbcType="DECIMAL"/> .... <collection property="skus" select="selectSkuByPk1" column="ID"/> </resultMap> <select id="select resultMap="InfoResultMap"> select p.id ,i.ID as INFO_ID from md_product,md_product_info i where .... </select> there are error info
org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'ID' from result set. Cause: java.sql.SQLException: Invalid value for getLong() - '82620ef6659811e9809900163e02c6cf' I debug it and try fix it
class: org.apache.ibatis.type.UnknownTypeHandler method: private TypeHandler<?> resolveTypeHandler(ResultSet rs, String column) old code:
private TypeHandler<?> resolveTypeHandler(ResultSet rs, String column) { try { Map<String, Integer> columnIndexLookup = new HashMap(); ResultSetMetaData rsmd = rs.getMetaData(); int count = rsmd.getColumnCount(); for (int i = 1; i <= count; ++i) { String name = rsmd.getColumnName(i); columnIndexLookup.put(name, i); } Integer columnIndex = (Integer) columnIndexLookup.get(column); TypeHandler<?> handler = null; if (columnIndex != null) { handler = this.resolveTypeHandler(rsmd, columnIndex); } if (handler == null || handler instanceof UnknownTypeHandler) { handler = OBJECT_TYPE_HANDLER; } return (TypeHandler) handler; } catch (SQLException var8) { throw new TypeException("Error determining JDBC type for column " + column + ". Cause: " + var8, var8); } } this is my code:
private TypeHandler<?> resolveTypeHandler(ResultSet rs, String column) { try { Map<String, Integer> columnIndexLookup = new HashMap(); ResultSetMetaData rsmd = rs.getMetaData(); int count = rsmd.getColumnCount(); for (int i = 1; i <= count; ++i) { String name = rsmd.getColumnLabel(i); columnIndexLookup.put(name, i); } Integer columnIndex = (Integer) columnIndexLookup.get(column); TypeHandler<?> handler = null; if (columnIndex != null) { handler = this.resolveTypeHandler(rsmd, columnIndex); } if (handler == null || handler instanceof UnknownTypeHandler) { handler = OBJECT_TYPE_HANDLER; } return (TypeHandler) handler; } catch (SQLException var8) { throw new TypeException("Error determining JDBC type for column " + column + ". Cause: " + var8, var8); } } getColumnName = > getColumnLabel
it works but i don't know there are any other bugs after i fixed this bug