Skip to content

Commit fa7001c

Browse files
committed
avoid introspecting the resultset
1 parent d722dd5 commit fa7001c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/main/java/org/apache/ibatis/executor/resultset/FastResultSetHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ protected Object createPrimitiveResultObject(ResultSet rs, ResultMap resultMap,
419419
final ResultMapping mapping = resultMappingList.get(0);
420420
columnName = prependPrefix(mapping.getColumn(), columnPrefix);
421421
} else {
422-
final ResultSetMetaData rsmd = rs.getMetaData();
423-
columnName = configuration.isUseColumnLabel() ? rsmd.getColumnLabel(1) : rsmd.getColumnName(1);
422+
columnName = resultColumnCache.getColumnNames().get(0);
424423
}
425424
final TypeHandler<?> typeHandler = resultColumnCache.getTypeHandler(resultType, columnName);
426425
return typeHandler.getResult(rs, columnName);
@@ -587,6 +586,10 @@ protected ResultColumnCache(ResultSetMetaData metaData, Configuration configurat
587586
}
588587
}
589588

589+
protected List<String> getColumnNames() {
590+
return this.columnNames;
591+
}
592+
590593
protected JdbcType getJdbcType(String columnName) {
591594
final int index = columnNames.indexOf(columnName);
592595
return jdbcTypes.get(index);

src/main/java/org/apache/ibatis/executor/resultset/NestedResultSetHandler.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.apache.ibatis.executor.resultset;
1717

1818
import java.sql.ResultSet;
19-
import java.sql.ResultSetMetaData;
2019
import java.sql.SQLException;
2120
import java.util.HashMap;
2221
import java.util.List;
@@ -247,7 +246,7 @@ private CacheKey createRowKey(ResultMap resultMap, ResultSet rs, String columnPr
247246
List<ResultMapping> resultMappings = getResultMappingsForRowKey(resultMap);
248247
if (resultMappings.size() == 0) {
249248
if (Map.class.isAssignableFrom(resultMap.getType())) {
250-
createRowKeyForMap(rs, cacheKey);
249+
createRowKeyForMap(rs, cacheKey, resultColumnCache);
251250
} else {
252251
createRowKeyForUnmappedProperties(resultMap, rs, cacheKey, columnPrefix, resultColumnCache);
253252
}
@@ -322,16 +321,14 @@ private void createRowKeyForUnmappedProperties(ResultMap resultMap, ResultSet rs
322321
}
323322
}
324323

325-
private void createRowKeyForMap(ResultSet rs, CacheKey cacheKey) throws SQLException {
326-
final ResultSetMetaData rsmd = rs.getMetaData();
327-
final int columnCount = rsmd.getColumnCount();
328-
for (int i = 1; i <= columnCount; i++) {
329-
final String columnName = configuration.isUseColumnLabel() ? rsmd.getColumnLabel(i) : rsmd.getColumnName(i);
324+
private void createRowKeyForMap(ResultSet rs, CacheKey cacheKey, ResultColumnCache resultColumnCache) throws SQLException {
325+
List<String> columnNames = resultColumnCache.getColumnNames();
326+
for (String columnName : columnNames) {
330327
final String value = rs.getString(columnName);
331328
if (value != null) {
332329
cacheKey.update(columnName);
333330
cacheKey.update(value);
334-
}
331+
}
335332
}
336333
}
337334

0 commit comments

Comments
 (0)