コード例 #1
0
 private Object getNestedQueryConstructorValue(
     ResultSet rs, ResultMapping constructorMapping, String columnPrefix) throws SQLException {
   final String nestedQueryId = constructorMapping.getNestedQueryId();
   final MappedStatement nestedQuery = configuration.getMappedStatement(nestedQueryId);
   final Class<?> nestedQueryParameterType = nestedQuery.getParameterMap().getType();
   final Object nestedQueryParameterObject =
       prepareParameterForNestedQuery(
           rs, constructorMapping, nestedQueryParameterType, columnPrefix);
   Object value = null;
   if (nestedQueryParameterObject != null) {
     final BoundSql nestedBoundSql = nestedQuery.getBoundSql(nestedQueryParameterObject);
     final CacheKey key =
         executor.createCacheKey(
             nestedQuery, nestedQueryParameterObject, RowBounds.DEFAULT, nestedBoundSql);
     final Class<?> targetType = constructorMapping.getJavaType();
     final ResultLoader resultLoader =
         new ResultLoader(
             configuration,
             executor,
             nestedQuery,
             nestedQueryParameterObject,
             targetType,
             key,
             nestedBoundSql);
     value = resultLoader.loadResult();
   }
   return value;
 }
コード例 #2
0
 private Object getNestedQueryMappingValue(
     ResultSet rs,
     MetaObject metaResultObject,
     ResultMapping propertyMapping,
     ResultLoaderMap lazyLoader,
     String columnPrefix)
     throws SQLException {
   final String nestedQueryId = propertyMapping.getNestedQueryId();
   final String property = propertyMapping.getProperty();
   final MappedStatement nestedQuery = configuration.getMappedStatement(nestedQueryId);
   final Class<?> nestedQueryParameterType = nestedQuery.getParameterMap().getType();
   final Object nestedQueryParameterObject =
       prepareParameterForNestedQuery(rs, propertyMapping, nestedQueryParameterType, columnPrefix);
   Object value = NO_VALUE;
   if (nestedQueryParameterObject != null) {
     final BoundSql nestedBoundSql = nestedQuery.getBoundSql(nestedQueryParameterObject);
     final CacheKey key =
         executor.createCacheKey(
             nestedQuery, nestedQueryParameterObject, RowBounds.DEFAULT, nestedBoundSql);
     final Class<?> targetType = propertyMapping.getJavaType();
     if (executor.isCached(nestedQuery, key)) {
       executor.deferLoad(nestedQuery, metaResultObject, property, key, targetType);
     } else {
       final ResultLoader resultLoader =
           new ResultLoader(
               configuration,
               executor,
               nestedQuery,
               nestedQueryParameterObject,
               targetType,
               key,
               nestedBoundSql);
       if (propertyMapping.isLazy()) {
         lazyLoader.addLoader(property, metaResultObject, resultLoader);
       } else {
         value = resultLoader.loadResult();
       }
     }
   }
   return value;
 }