|
16 | 16 | package org.apache.ibatis.executor.resultset;
|
17 | 17 |
|
18 | 18 | import java.sql.ResultSet;
|
19 |
| -import java.sql.ResultSetMetaData; |
20 | 19 | import java.sql.SQLException;
|
21 | 20 | import java.util.HashMap;
|
22 | 21 | import java.util.List;
|
@@ -247,7 +246,7 @@ private CacheKey createRowKey(ResultMap resultMap, ResultSet rs, String columnPr
|
247 | 246 | List<ResultMapping> resultMappings = getResultMappingsForRowKey(resultMap);
|
248 | 247 | if (resultMappings.size() == 0) {
|
249 | 248 | if (Map.class.isAssignableFrom(resultMap.getType())) {
|
250 |
| - createRowKeyForMap(rs, cacheKey); |
| 249 | + createRowKeyForMap(rs, cacheKey, resultColumnCache); |
251 | 250 | } else {
|
252 | 251 | createRowKeyForUnmappedProperties(resultMap, rs, cacheKey, columnPrefix, resultColumnCache);
|
253 | 252 | }
|
@@ -322,16 +321,14 @@ private void createRowKeyForUnmappedProperties(ResultMap resultMap, ResultSet rs
|
322 | 321 | }
|
323 | 322 | }
|
324 | 323 |
|
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) { |
330 | 327 | final String value = rs.getString(columnName);
|
331 | 328 | if (value != null) {
|
332 | 329 | cacheKey.update(columnName);
|
333 | 330 | cacheKey.update(value);
|
334 |
| - } |
| 331 | + } |
335 | 332 | }
|
336 | 333 | }
|
337 | 334 |
|
|
0 commit comments