@@ -252,7 +252,7 @@ private CacheKey createRowKey(ResultMap resultMap, ResultSet rs, String columnPr
252
252
createRowKeyForUnmappedProperties (resultMap , rs , cacheKey , columnPrefix , resultColumnCache );
253
253
}
254
254
} else {
255
- createRowKeyForMappedProperties (rs , cacheKey , resultMappings , columnPrefix );
255
+ createRowKeyForMappedProperties (resultMap , rs , cacheKey , resultMappings , columnPrefix , resultColumnCache );
256
256
}
257
257
if (cacheKey .getUpdateCount () < 2 ) {
258
258
return CacheKey .NULL_CACHE_KEY ;
@@ -277,16 +277,17 @@ private List<ResultMapping> getResultMappingsForRowKey(ResultMap resultMap) {
277
277
return resultMappings ;
278
278
}
279
279
280
- private void createRowKeyForMappedProperties (ResultSet rs , CacheKey cacheKey , List <ResultMapping > resultMappings , String columnPrefix ) throws SQLException {
280
+ private void createRowKeyForMappedProperties (ResultMap resultMap , ResultSet rs , CacheKey cacheKey , List <ResultMapping > resultMappings , String columnPrefix , ResultColumnCache resultColumnCache ) throws SQLException {
281
281
for (ResultMapping resultMapping : resultMappings ) {
282
282
if (resultMapping .getNestedResultMapId () != null ) {
283
- final ResultMap myResultMap = configuration .getResultMap (resultMapping .getNestedResultMapId ());
284
- createRowKeyForMappedProperties (rs , cacheKey , myResultMap .getConstructorResultMappings (),
285
- prependPrefix (resultMapping .getColumnPrefix (), columnPrefix ));
283
+ final ResultMap nestedResultMap = configuration .getResultMap (resultMapping .getNestedResultMapId ());
284
+ createRowKeyForMappedProperties (nestedResultMap , rs , cacheKey , nestedResultMap .getConstructorResultMappings (),
285
+ prependPrefix (resultMapping .getColumnPrefix (), columnPrefix ), resultColumnCache );
286
286
} else if (resultMapping .getNestedQueryId () == null ) {
287
287
final String column = prependPrefix (resultMapping .getColumn (), columnPrefix );
288
288
final TypeHandler <?> th = resultMapping .getTypeHandler ();
289
- if (column != null && resultSetHasColumn (rs , column )) { // issue #114
289
+ List <String > mappedColumnNames = resultColumnCache .getMappedColumnNames (resultMap , columnPrefix );
290
+ if (column != null && mappedColumnNames .contains (column .toUpperCase (Locale .ENGLISH ))) { // issue #114
290
291
final Object value = th .getResult (rs , column );
291
292
if (value != null ) {
292
293
cacheKey .update (column );
@@ -334,20 +335,4 @@ private void createRowKeyForMap(ResultSet rs, CacheKey cacheKey) throws SQLExcep
334
335
}
335
336
}
336
337
337
- protected boolean resultSetHasColumn (final ResultSet rs , final String column ) {
338
- try {
339
- final ResultSetMetaData rsmd = rs .getMetaData ();
340
- final int columnCount = rsmd .getColumnCount ();
341
- for (int i = 1 ; i <= columnCount ; i ++) {
342
- final String label = rsmd .getColumnLabel (i );
343
- if (column .equalsIgnoreCase (label )) {
344
- return true ;
345
- }
346
- }
347
- } catch (final SQLException e ) {
348
- // ignore
349
- }
350
- return false ;
351
- }
352
-
353
338
}
0 commit comments