@@ -206,8 +206,18 @@ public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBo
206
206
// mimic DefaultParameterHandler logic
207
207
for (ParameterMapping parameterMapping : parameterMappings ) {
208
208
if (parameterMapping .getMode () != ParameterMode .OUT ) {
209
+ Object value ;
209
210
String propertyName = parameterMapping .getProperty ();
210
- Object value = parseCacheValue (parameterObject , boundSql , typeHandlerRegistry , propertyName , configuration );
211
+ if (boundSql .hasAdditionalParameter (propertyName )) {
212
+ value = boundSql .getAdditionalParameter (propertyName );
213
+ } else if (parameterObject == null ) {
214
+ value = null ;
215
+ } else if (typeHandlerRegistry .hasTypeHandler (parameterObject .getClass ())) {
216
+ value = parameterObject ;
217
+ } else {
218
+ MetaObject metaObject = configuration .newMetaObject (parameterObject );
219
+ value = metaObject .getValue (propertyName );
220
+ }
211
221
cacheKey .update (value );
212
222
}
213
223
}
@@ -218,23 +228,6 @@ public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBo
218
228
return cacheKey ;
219
229
}
220
230
221
- public static Object parseCacheValue (Object parameterObject , BoundSql boundSql ,
222
- TypeHandlerRegistry typeHandlerRegistry ,
223
- String propertyName , Configuration configuration ) {
224
- Object value ;
225
- if (boundSql .hasAdditionalParameter (propertyName )) {
226
- value = boundSql .getAdditionalParameter (propertyName );
227
- } else if (parameterObject == null ) {
228
- value = null ;
229
- } else if (typeHandlerRegistry .hasTypeHandler (parameterObject .getClass ())) {
230
- value = parameterObject ;
231
- } else {
232
- MetaObject metaObject = configuration .newMetaObject (parameterObject );
233
- value = metaObject .getValue (propertyName );
234
- }
235
- return value ;
236
- }
237
-
238
231
@ Override
239
232
public boolean isCached (MappedStatement ms , CacheKey key ) {
240
233
return localCache .getObject (key ) != null ;
@@ -279,10 +272,10 @@ public void clearLocalCache() {
279
272
protected abstract List <BatchResult > doFlushStatements (boolean isRollback ) throws SQLException ;
280
273
281
274
protected abstract <E > List <E > doQuery (MappedStatement ms , Object parameter , RowBounds rowBounds , ResultHandler resultHandler , BoundSql boundSql )
282
- throws SQLException ;
275
+ throws SQLException ;
283
276
284
277
protected abstract <E > Cursor <E > doQueryCursor (MappedStatement ms , Object parameter , RowBounds rowBounds , BoundSql boundSql )
285
- throws SQLException ;
278
+ throws SQLException ;
286
279
287
280
protected void closeStatement (Statement statement ) {
288
281
if (statement != null ) {
@@ -366,11 +359,11 @@ private static class DeferredLoad {
366
359
367
360
// issue #781
368
361
public DeferredLoad (MetaObject resultObject ,
369
- String property ,
370
- CacheKey key ,
371
- PerpetualCache localCache ,
372
- Configuration configuration ,
373
- Class <?> targetType ) {
362
+ String property ,
363
+ CacheKey key ,
364
+ PerpetualCache localCache ,
365
+ Configuration configuration ,
366
+ Class <?> targetType ) {
374
367
this .resultObject = resultObject ;
375
368
this .property = property ;
376
369
this .key = key ;
@@ -387,7 +380,7 @@ public boolean canLoad() {
387
380
public void load () {
388
381
@ SuppressWarnings ("unchecked" )
389
382
// we suppose we get back a List
390
- List <Object > list = (List <Object >) localCache .getObject (key );
383
+ List <Object > list = (List <Object >) localCache .getObject (key );
391
384
Object value = resultExtractor .extractObjectFromList (list , targetType );
392
385
resultObject .setValue (property , value );
393
386
}
0 commit comments