mybatis resulttype如何获取List<Object[]>?
展开全部
具体可以看org.apache.ibatis.type.TypeAliasRegistry类第68行。
然后修改org.apache.ibatis.executor.resultset.FastResultSetHandler类
在方法protected Object getRowValue(ResultSet rs, ResultMap resultMap, CacheKey rowKey) throws SQLException中添加
final Class resultType = resultMap.getType();
if (resultType == Object[].class) {
foundValues = true;
}
在方法protected Object createResultObject(ResultSet rs, ResultMap resultMap, List<Class> constructorArgTypes, List<Object> constructorArgs) throws SQLException中添加
else if (resultType == Object[].class) {
final ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
Object[] result = new Object[columnCount];
for (int i = 0; i < columnCount; i++) {
result[i] = rs.getString(i + 1);
}
return result;
}
然后修改org.apache.ibatis.executor.resultset.FastResultSetHandler类
在方法protected Object getRowValue(ResultSet rs, ResultMap resultMap, CacheKey rowKey) throws SQLException中添加
final Class resultType = resultMap.getType();
if (resultType == Object[].class) {
foundValues = true;
}
在方法protected Object createResultObject(ResultSet rs, ResultMap resultMap, List<Class> constructorArgTypes, List<Object> constructorArgs) throws SQLException中添加
else if (resultType == Object[].class) {
final ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
Object[] result = new Object[columnCount];
for (int i = 0; i < columnCount; i++) {
result[i] = rs.getString(i + 1);
}
return result;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询