当前位置: 首页>>代码示例>>Java>>正文


Java ResultLoaderMap类代码示例

本文整理汇总了Java中org.apache.ibatis.executor.loader.ResultLoaderMap的典型用法代码示例。如果您正苦于以下问题:Java ResultLoaderMap类的具体用法?Java ResultLoaderMap怎么用?Java ResultLoaderMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResultLoaderMap类属于org.apache.ibatis.executor.loader包,在下文中一共展示了ResultLoaderMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRowValue

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private Object getRowValue(ResultSetWrapper rsw, ResultMap resultMap) throws SQLException {
  final ResultLoaderMap lazyLoader = new ResultLoaderMap();
  Object resultObject = createResultObject(rsw, resultMap, lazyLoader, null);
  if (resultObject != null && !hasTypeHandlerForResultObject(rsw, resultMap.getType())) {
    final MetaObject metaObject = configuration.newMetaObject(resultObject);
    boolean foundValues = !resultMap.getConstructorResultMappings().isEmpty();
    if (shouldApplyAutomaticMappings(resultMap, false)) {
      foundValues = applyAutomaticMappings(rsw, resultMap, metaObject, null) || foundValues;
    }
    foundValues = applyPropertyMappings(rsw, resultMap, metaObject, lazyLoader, null) || foundValues;
    foundValues = lazyLoader.size() > 0 || foundValues;
    resultObject = foundValues ? resultObject : null;
    return resultObject;
  }
  return resultObject;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:DefaultResultSetHandler.java

示例2: getRowValue

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private Object getRowValue(ResultSetWrapper rsw, ResultMap resultMap) throws SQLException {
  //实例化ResultLoaderMap(延迟加载器)
  final ResultLoaderMap lazyLoader = new ResultLoaderMap();
  //调用自己的createResultObject,内部就是new一个对象(如果是简单类型,new完也把值赋进去)
  Object resultObject = createResultObject(rsw, resultMap, lazyLoader, null);
  if (resultObject != null && !typeHandlerRegistry.hasTypeHandler(resultMap.getType())) {
    //一般不是简单类型不会有typehandler,这个if会进来
    final MetaObject metaObject = configuration.newMetaObject(resultObject);
    boolean foundValues = !resultMap.getConstructorResultMappings().isEmpty();
    if (shouldApplyAutomaticMappings(resultMap, false)) {        
      //自动映射咯
      //这里把每个列的值都赋到相应的字段里去了
  	foundValues = applyAutomaticMappings(rsw, resultMap, metaObject, null) || foundValues;
    }
    foundValues = applyPropertyMappings(rsw, resultMap, metaObject, lazyLoader, null) || foundValues;
    foundValues = lazyLoader.size() > 0 || foundValues;
    resultObject = foundValues ? resultObject : null;
    return resultObject;
  }
  return resultObject;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:22,代码来源:DefaultResultSetHandler.java

示例3: createResultObject

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
  final List<Class<?>> constructorArgTypes = new ArrayList<Class<?>>();
  final List<Object> constructorArgs = new ArrayList<Object>();
  final Object resultObject = createResultObject(rsw, resultMap, constructorArgTypes, constructorArgs, columnPrefix);
  if (resultObject != null && !typeHandlerRegistry.hasTypeHandler(resultMap.getType())) {
    final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
    for (ResultMapping propertyMapping : propertyMappings) {
      // issue gcode #109 && issue #149
      if (propertyMapping.getNestedQueryId() != null && propertyMapping.isLazy()) {
        //TODO 使用代理(cglib/javaassist)
        return configuration.getProxyFactory().createProxy(resultObject, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs);
      }
    }
  }
  return resultObject;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:17,代码来源:DefaultResultSetHandler.java

示例4: getRowValue

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private Object getRowValue(ResultSetWrapper rsw, ResultMap resultMap) throws SQLException {
  final ResultLoaderMap lazyLoader = new ResultLoaderMap();
  Object resultObject = createResultObject(rsw, resultMap, lazyLoader, null);
  if (resultObject != null && !typeHandlerRegistry.hasTypeHandler(resultMap.getType())) {
    final MetaObject metaObject = configuration.newMetaObject(resultObject);
    boolean foundValues = !resultMap.getConstructorResultMappings().isEmpty();
    if (shouldApplyAutomaticMappings(resultMap, false)) {
      foundValues = applyAutomaticMappings(rsw, resultMap, metaObject, null) || foundValues;
    }
    foundValues = applyPropertyMappings(rsw, resultMap, metaObject, lazyLoader, null) || foundValues;
    foundValues = lazyLoader.size() > 0 || foundValues;
    resultObject = foundValues ? resultObject : null;
    return resultObject;
  }
  return resultObject;
}
 
开发者ID:toulezu,项目名称:play,代码行数:17,代码来源:DefaultResultSetHandler.java

示例5: getRowValue

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
protected Object getRowValue(ResultSet rs, ResultMap resultMap, CacheKey rowKey, ResultColumnCache resultColumnCache) throws SQLException {
  final ResultLoaderMap lazyLoader = instantiateResultLoaderMap();
  Object resultObject = createResultObject(rs, resultMap, lazyLoader, null, resultColumnCache);
  if (resultObject != null && !typeHandlerRegistry.hasTypeHandler(resultMap.getType())) {
    final MetaObject metaObject = configuration.newMetaObject(resultObject);
    boolean foundValues = resultMap.getConstructorResultMappings().size() > 0;
    if (shouldApplyAutomaticMappings(resultMap, !AutoMappingBehavior.NONE.equals(configuration.getAutoMappingBehavior()))) {
      final List<String> unmappedColumnNames = resultColumnCache.getUnmappedColumnNames(resultMap, null);
      foundValues = applyAutomaticMappings(rs, unmappedColumnNames, metaObject, null, resultColumnCache) || foundValues;
    }
    final List<String> mappedColumnNames = resultColumnCache.getMappedColumnNames(resultMap, null);
    foundValues = applyPropertyMappings(rs, resultMap, mappedColumnNames, metaObject, lazyLoader, null) || foundValues;
    foundValues = (lazyLoader != null && lazyLoader.size() > 0) || foundValues;
    resultObject = foundValues ? resultObject : null;
    return resultObject;
  }
  return resultObject;
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:19,代码来源:FastResultSetHandler.java

示例6: applyPropertyMappings

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
protected boolean applyPropertyMappings(ResultSet rs, ResultMap resultMap, List<String> mappedColumnNames, MetaObject metaObject, ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
  boolean foundValues = false;
  final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
  for (ResultMapping propertyMapping : propertyMappings) {
    final String column = prependPrefix(propertyMapping.getColumn(), columnPrefix);
    if (propertyMapping.isCompositeResult() || (column != null && mappedColumnNames.contains(column.toUpperCase(Locale.ENGLISH)))) {
      Object value = getPropertyMappingValue(rs, metaObject, propertyMapping, lazyLoader, columnPrefix);
    //  if (value != null) {
        final String property = propertyMapping.getProperty(); // issue #541 make property optional
        if (property != null) {
          metaObject.setValue(property, value);
          foundValues = true;
        }
     // }
    }
  }
  return foundValues;
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:19,代码来源:FastResultSetHandler.java

示例7: getNestedQueryMappingValue

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
protected 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 = null;
  if (nestedQueryParameterObject != null) {
    final BoundSql nestedBoundSql = nestedQuery.getBoundSql(nestedQueryParameterObject);
    final CacheKey key = executor.createCacheKey(nestedQuery, nestedQueryParameterObject, RowBounds.DEFAULT, nestedBoundSql);
    if (executor.isCached(nestedQuery, key)) {
      executor.deferLoad(nestedQuery, metaResultObject, property, key);
    } else {
      final ResultLoader resultLoader = new ResultLoader(configuration, executor, nestedQuery, nestedQueryParameterObject, propertyMapping.getJavaType(), key, nestedBoundSql);
      if (configuration.isLazyLoadingEnabled()) {
        lazyLoader.addLoader(property, metaResultObject, resultLoader);
      } else {
        value = resultLoader.loadResult();
      }
    }
  }
  return value;
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:24,代码来源:FastResultSetHandler.java

示例8: createResultObject

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
  this.useConstructorMappings = false; // reset previous mapping result
  final List<Class<?>> constructorArgTypes = new ArrayList<Class<?>>();
  final List<Object> constructorArgs = new ArrayList<Object>();
  Object resultObject = createResultObject(rsw, resultMap, constructorArgTypes, constructorArgs, columnPrefix);
  if (resultObject != null && !hasTypeHandlerForResultObject(rsw, resultMap.getType())) {
    final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
    for (ResultMapping propertyMapping : propertyMappings) {
      // issue gcode #109 && issue #149
      if (propertyMapping.getNestedQueryId() != null && propertyMapping.isLazy()) {
        resultObject = configuration.getProxyFactory().createProxy(resultObject, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs);
        break;
      }
    }
  }
  this.useConstructorMappings = resultObject != null && !constructorArgTypes.isEmpty(); // set current mapping result
  return resultObject;
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:19,代码来源:DefaultResultSetHandler.java

示例9: applyPropertyMappings

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private boolean applyPropertyMappings(ResultSetWrapper rsw, ResultMap resultMap, MetaObject metaObject, ResultLoaderMap lazyLoader, String columnPrefix)
    throws SQLException {
  final List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
  boolean foundValues = false;
  final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
  for (ResultMapping propertyMapping : propertyMappings) {
    String column = prependPrefix(propertyMapping.getColumn(), columnPrefix);
    if (propertyMapping.getNestedResultMapId() != null) {
      // the user added a column attribute to a nested result map, ignore it
      column = null;
    }
    if (propertyMapping.isCompositeResult()
        || (column != null && mappedColumnNames.contains(column.toUpperCase(Locale.ENGLISH)))
        || propertyMapping.getResultSet() != null) {
      Object value = getPropertyMappingValue(rsw.getResultSet(), metaObject, propertyMapping, lazyLoader, columnPrefix);
      // issue #541 make property optional
      final String property = propertyMapping.getProperty();
      if (property == null) {
        continue;
      } else if (value == DEFERED) {
        foundValues = true;
        continue;
      }
      if (value != null) {
        foundValues = true;
      }
      if (value != null || (configuration.isCallSettersOnNulls() && !metaObject.getSetterType(property).isPrimitive())) {
        // gcode issue #377, call setter on nulls (value is not 'found')
        metaObject.setValue(property, value);
      }
    }
  }
  return foundValues;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:35,代码来源:DefaultResultSetHandler.java

示例10: getPropertyMappingValue

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private Object getPropertyMappingValue(ResultSet rs, MetaObject metaResultObject, ResultMapping propertyMapping, ResultLoaderMap lazyLoader, String columnPrefix)
    throws SQLException {
  if (propertyMapping.getNestedQueryId() != null) {
    return getNestedQueryMappingValue(rs, metaResultObject, propertyMapping, lazyLoader, columnPrefix);
  } else if (propertyMapping.getResultSet() != null) {
    addPendingChildRelation(rs, metaResultObject, propertyMapping);   // TODO is that OK?
    return DEFERED;
  } else {
    final TypeHandler<?> typeHandler = propertyMapping.getTypeHandler();
    final String column = prependPrefix(propertyMapping.getColumn(), columnPrefix);
    return typeHandler.getResult(rs, column);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:14,代码来源:DefaultResultSetHandler.java

示例11: createResultObject

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private Object createResultObject(ResultSetWrapper rsw, ResultMap resultMap, ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
  final List<Class<?>> constructorArgTypes = new ArrayList<Class<?>>();
  final List<Object> constructorArgs = new ArrayList<Object>();
  final Object resultObject = createResultObject(rsw, resultMap, constructorArgTypes, constructorArgs, columnPrefix);
  if (resultObject != null && !hasTypeHandlerForResultObject(rsw, resultMap.getType())) {
    final List<ResultMapping> propertyMappings = resultMap.getPropertyResultMappings();
    for (ResultMapping propertyMapping : propertyMappings) {
      // issue gcode #109 && issue #149
      if (propertyMapping.getNestedQueryId() != null && propertyMapping.isLazy()) {
        return configuration.getProxyFactory().createProxy(resultObject, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs);
      }
    }
  }
  return resultObject;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:16,代码来源:DefaultResultSetHandler.java

示例12: getNestedQueryMappingValue

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
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 = null;
  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);
      value = DEFERED;
    } else {
      final ResultLoader resultLoader = new ResultLoader(configuration, executor, nestedQuery, nestedQueryParameterObject, targetType, key, nestedBoundSql);
      if (propertyMapping.isLazy()) {
        lazyLoader.addLoader(property, metaResultObject, resultLoader);
        value = DEFERED;
      } else {
        value = resultLoader.loadResult();
      }
    }
  }
  return value;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:28,代码来源:DefaultResultSetHandler.java

示例13: JavassistSerialStateHolder

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
public JavassistSerialStateHolder(
        final Object userBean,
        final Map<String, ResultLoaderMap.LoadPair> unloadedProperties,
        final ObjectFactory objectFactory,
        List<Class<?>> constructorArgTypes,
        List<Object> constructorArgs) {
  super(userBean, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:JavassistSerialStateHolder.java

示例14: EnhancedResultObjectProxyImpl

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
private EnhancedResultObjectProxyImpl(Class<?> type, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  this.type = type;
  this.lazyLoader = lazyLoader;
  this.aggressive = configuration.isAggressiveLazyLoading();
  this.lazyLoadTriggerMethods = configuration.getLazyLoadTriggerMethods();
  this.objectFactory = objectFactory;
  this.constructorArgTypes = constructorArgTypes;
  this.constructorArgs = constructorArgs;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:10,代码来源:JavassistProxyFactory.java

示例15: createProxy

import org.apache.ibatis.executor.loader.ResultLoaderMap; //导入依赖的package包/类
public static Object createProxy(Object target, ResultLoaderMap lazyLoader, Configuration configuration, ObjectFactory objectFactory, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
  final Class<?> type = target.getClass();
  EnhancedResultObjectProxyImpl callback = new EnhancedResultObjectProxyImpl(type, lazyLoader, configuration, objectFactory, constructorArgTypes, constructorArgs);
  Object enhanced = crateProxy(type, callback, constructorArgTypes, constructorArgs);
  PropertyCopier.copyBeanProperties(type, target, enhanced);
  return enhanced;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:JavassistProxyFactory.java


注:本文中的org.apache.ibatis.executor.loader.ResultLoaderMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。