當前位置: 首頁>>代碼示例>>Java>>正文


Java TypeHandler.getResult方法代碼示例

本文整理匯總了Java中org.apache.ibatis.type.TypeHandler.getResult方法的典型用法代碼示例。如果您正苦於以下問題:Java TypeHandler.getResult方法的具體用法?Java TypeHandler.getResult怎麽用?Java TypeHandler.getResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.ibatis.type.TypeHandler的用法示例。


在下文中一共展示了TypeHandler.getResult方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createByConstructorSignature

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private Object createByConstructorSignature(ResultSetWrapper rsw, Class<?> resultType, List<Class<?>> constructorArgTypes, List<Object> constructorArgs,
    String columnPrefix) throws SQLException {
  for (Constructor<?> constructor : resultType.getDeclaredConstructors()) {
    if (typeNames(constructor.getParameterTypes()).equals(rsw.getClassNames())) {
      boolean foundValues = false;
      for (int i = 0; i < constructor.getParameterTypes().length; i++) {
        Class<?> parameterType = constructor.getParameterTypes()[i];
        String columnName = rsw.getColumnNames().get(i);
        TypeHandler<?> typeHandler = rsw.getTypeHandler(parameterType, columnName);
        Object value = typeHandler.getResult(rsw.getResultSet(), prependPrefix(columnName, columnPrefix));
        constructorArgTypes.add(parameterType);
        constructorArgs.add(value);
        foundValues = value != null || foundValues;
      }
      return foundValues ? objectFactory.create(resultType, constructorArgTypes, constructorArgs) : null;
    }
  }
  throw new ExecutorException("No constructor found in " + resultType.getName() + " matching " + rsw.getClassNames());
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:20,代碼來源:DefaultResultSetHandler.java

示例2: prepareCompositeKeyParameter

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private Object prepareCompositeKeyParameter(ResultSet rs, ResultMapping resultMapping, Class<?> parameterType, String columnPrefix) throws SQLException {
  final Object parameterObject = instantiateParameterObject(parameterType);
  final MetaObject metaObject = configuration.newMetaObject(parameterObject);
  boolean foundValues = false;
  for (ResultMapping innerResultMapping : resultMapping.getComposites()) {
    final Class<?> propType = metaObject.getSetterType(innerResultMapping.getProperty());
    final TypeHandler<?> typeHandler = typeHandlerRegistry.getTypeHandler(propType);
    final Object propValue = typeHandler.getResult(rs, prependPrefix(innerResultMapping.getColumn(), columnPrefix));
    // issue #353 & #560 do not execute nested query if key is null
    if (propValue != null) {
      metaObject.setValue(innerResultMapping.getProperty(), propValue);
      foundValues = true;
    }
  }
  return foundValues ? parameterObject : null;
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:17,代碼來源:DefaultResultSetHandler.java

示例3: createRowKeyForMappedProperties

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private void createRowKeyForMappedProperties(ResultMap resultMap, ResultSetWrapper rsw, CacheKey cacheKey, List<ResultMapping> resultMappings, String columnPrefix) throws SQLException {
  for (ResultMapping resultMapping : resultMappings) {
    if (resultMapping.getNestedResultMapId() != null && resultMapping.getResultSet() == null) {
      // Issue #392
      final ResultMap nestedResultMap = configuration.getResultMap(resultMapping.getNestedResultMapId());
      createRowKeyForMappedProperties(nestedResultMap, rsw, cacheKey, nestedResultMap.getConstructorResultMappings(),
          prependPrefix(resultMapping.getColumnPrefix(), columnPrefix));
    } else if (resultMapping.getNestedQueryId() == null) {
      final String column = prependPrefix(resultMapping.getColumn(), columnPrefix);
      final TypeHandler<?> th = resultMapping.getTypeHandler();
      List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
      // Issue #114
      if (column != null && mappedColumnNames.contains(column.toUpperCase(Locale.ENGLISH))) {
        final Object value = th.getResult(rsw.getResultSet(), column);
        if (value != null) {
          cacheKey.update(column);
          cacheKey.update(value);
        }
      }
    }
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:23,代碼來源:DefaultResultSetHandler.java

示例4: createParameterizedResultObject

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private Object createParameterizedResultObject(ResultSetWrapper rsw, Class<?> resultType, List<ResultMapping> constructorMappings,
    List<Class<?>> constructorArgTypes, List<Object> constructorArgs, String columnPrefix) throws SQLException {
  boolean foundValues = false;
  for (ResultMapping constructorMapping : constructorMappings) {
    final Class<?> parameterType = constructorMapping.getJavaType();
    final String column = constructorMapping.getColumn();
    final Object value;
    if (constructorMapping.getNestedQueryId() != null) {
      value = getNestedQueryConstructorValue(rsw.getResultSet(), constructorMapping, columnPrefix);
    } else if (constructorMapping.getNestedResultMapId() != null) {
      final ResultMap resultMap = configuration.getResultMap(constructorMapping.getNestedResultMapId());
      value = getRowValue(rsw, resultMap);
    } else {
      final TypeHandler<?> typeHandler = constructorMapping.getTypeHandler();
      value = typeHandler.getResult(rsw.getResultSet(), prependPrefix(column, columnPrefix));
    }
    constructorArgTypes.add(parameterType);
    constructorArgs.add(value);
    foundValues = value != null || foundValues;
  }
  return foundValues ? objectFactory.create(resultType, constructorArgTypes, constructorArgs) : null;
}
 
開發者ID:shurun19851206,項目名稱:mybaties,代碼行數:23,代碼來源:DefaultResultSetHandler.java

示例5: createByConstructorSignature

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private Object createByConstructorSignature(ResultSetWrapper rsw, Class<?> resultType, List<Class<?>> constructorArgTypes, List<Object> constructorArgs,
    String columnPrefix) throws SQLException {
  for (Constructor<?> constructor : resultType.getDeclaredConstructors()) {
    if (typeNames(constructor.getParameterTypes()).equals(rsw.getClassNames())) {
      boolean foundValues = false;
      for (int i = 0; i < constructor.getParameterTypes().length; i++) {
        Class<?> parameterType = constructor.getParameterTypes()[i];
        String columnName = rsw.getColumnNames().get(i);
        TypeHandler<?> typeHandler = rsw.getTypeHandler(parameterType, columnName);
        Object value = typeHandler.getResult(rsw.getResultSet(), prependPrefix(columnName, columnPrefix));
        constructorArgTypes.add(parameterType);
        constructorArgs.add(value);
        foundValues = value != null || foundValues;
      }
      //上麵是構造函數創建對象,下麵是對象工廠來創建
      return foundValues ? objectFactory.create(resultType, constructorArgTypes, constructorArgs) : null;
    }
  }
  throw new ExecutorException("No constructor found in " + resultType.getName() + " matching " + rsw.getClassNames());
}
 
開發者ID:shurun19851206,項目名稱:mybaties,代碼行數:21,代碼來源:DefaultResultSetHandler.java

示例6: createRowKeyForMappedProperties

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private void createRowKeyForMappedProperties(ResultMap resultMap, ResultSetWrapper rsw, CacheKey cacheKey, List<ResultMapping> resultMappings, String columnPrefix) throws SQLException {
  for (ResultMapping resultMapping : resultMappings) {
    if (resultMapping.getNestedResultMapId() != null && resultMapping.getResultSet() == null) {
      // Issue #392
      final ResultMap nestedResultMap = configuration.getResultMap(resultMapping.getNestedResultMapId());
      createRowKeyForMappedProperties(nestedResultMap, rsw, cacheKey, nestedResultMap.getConstructorResultMappings(),
          prependPrefix(resultMapping.getColumnPrefix(), columnPrefix));
    } else if (resultMapping.getNestedQueryId() == null) {
      final String column = prependPrefix(resultMapping.getColumn(), columnPrefix);
      final TypeHandler<?> th = resultMapping.getTypeHandler();
      List<String> mappedColumnNames = rsw.getMappedColumnNames(resultMap, columnPrefix);
      // Issue #114
      if (column != null && mappedColumnNames.contains(column.toUpperCase(Locale.ENGLISH))) {
        final Object value = th.getResult(rsw.getResultSet(), column);
        if (value != null || configuration.isReturnInstanceForEmptyRow()) {
          cacheKey.update(column);
          cacheKey.update(value);
        }
      }
    }
  }
}
 
開發者ID:mybatis,項目名稱:mybatis-3,代碼行數:23,代碼來源:DefaultResultSetHandler.java

示例7: populateKeys

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private void populateKeys(ResultSet rs, MetaObject metaParam, String[] keyProperties, TypeHandler<?>[] typeHandlers) throws SQLException {
    for (int i = 0; i < keyProperties.length; i++) {
        TypeHandler<?> th = typeHandlers[i];
        if (th != null) {
            Object value = th.getResult(rs, i + 1);
            metaParam.setValue(keyProperties[i], value);
        }
    }
}
 
開發者ID:Yanweichen,項目名稱:MybatisGeneatorUtil,代碼行數:10,代碼來源:MultipleJdbc3KeyGenerator.java

示例8: getPropertyMappingValue

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的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

示例9: createPrimitiveResultObject

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private Object createPrimitiveResultObject(ResultSetWrapper rsw, ResultMap resultMap, String columnPrefix) throws SQLException {
  final Class<?> resultType = resultMap.getType();
  final String columnName;
  if (!resultMap.getResultMappings().isEmpty()) {
    final List<ResultMapping> resultMappingList = resultMap.getResultMappings();
    final ResultMapping mapping = resultMappingList.get(0);
    columnName = prependPrefix(mapping.getColumn(), columnPrefix);
  } else {
    columnName = rsw.getColumnNames().get(0);
  }
  final TypeHandler<?> typeHandler = rsw.getTypeHandler(resultType, columnName);
  return typeHandler.getResult(rsw.getResultSet(), columnName);
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:14,代碼來源:DefaultResultSetHandler.java

示例10: prepareSimpleKeyParameter

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private Object prepareSimpleKeyParameter(ResultSet rs, ResultMapping resultMapping, Class<?> parameterType, String columnPrefix) throws SQLException {
  final TypeHandler<?> typeHandler;
  if (typeHandlerRegistry.hasTypeHandler(parameterType)) {
    typeHandler = typeHandlerRegistry.getTypeHandler(parameterType);
  } else {
    typeHandler = typeHandlerRegistry.getUnknownTypeHandler();
  }
  return typeHandler.getResult(rs, prependPrefix(resultMapping.getColumn(), columnPrefix));
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:10,代碼來源:DefaultResultSetHandler.java

示例11: populateKeys

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private void populateKeys(ResultSet rs, MetaObject metaParam, String[] keyProperties, TypeHandler<?>[] typeHandlers) throws SQLException {
  for (int i = 0; i < keyProperties.length; i++) {
    TypeHandler<?> th = typeHandlers[i];
    if (th != null) {
      Object value = th.getResult(rs, i + 1);
      metaParam.setValue(keyProperties[i], value);
    }
  }
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:10,代碼來源:Jdbc3KeyGenerator.java

示例12: applyAutomaticMappings

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private boolean applyAutomaticMappings(ResultSetWrapper rsw, ResultMap resultMap, MetaObject metaObject, String columnPrefix) throws SQLException {
  final List<String> unmappedColumnNames = rsw.getUnmappedColumnNames(resultMap, columnPrefix);
  boolean foundValues = false;
  for (String columnName : unmappedColumnNames) {
    String propertyName = columnName;
    if (columnPrefix != null && !columnPrefix.isEmpty()) {
      // When columnPrefix is specified,
      // ignore columns without the prefix.
      if (columnName.toUpperCase(Locale.ENGLISH).startsWith(columnPrefix)) {
        propertyName = columnName.substring(columnPrefix.length());
      } else {
        continue;
      }
    }
    final String property = metaObject.findProperty(propertyName, configuration.isMapUnderscoreToCamelCase());
    if (property != null && metaObject.hasSetter(property)) {
      final Class<?> propertyType = metaObject.getSetterType(property);
      if (typeHandlerRegistry.hasTypeHandler(propertyType)) {
        final TypeHandler<?> typeHandler = rsw.getTypeHandler(propertyType, columnName);
        //巧妙的用TypeHandler取得結果
        final Object value = typeHandler.getResult(rsw.getResultSet(), columnName);
        // issue #377, call setter on nulls
        if (value != null || configuration.isCallSettersOnNulls()) {
          if (value != null || !propertyType.isPrimitive()) {
            //然後巧妙的用反射來設置到對象
            metaObject.setValue(property, value);
          }
          foundValues = true;
        }
      }
    }
  }
  return foundValues;
}
 
開發者ID:shurun19851206,項目名稱:mybaties,代碼行數:35,代碼來源:DefaultResultSetHandler.java

示例13: createPrimitiveResultObject

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private Object createPrimitiveResultObject(ResultSetWrapper rsw, ResultMap resultMap, String columnPrefix) throws SQLException {
  final Class<?> resultType = resultMap.getType();
  final String columnName;
  if (!resultMap.getResultMappings().isEmpty()) {
    final List<ResultMapping> resultMappingList = resultMap.getResultMappings();
    final ResultMapping mapping = resultMappingList.get(0);
    columnName = prependPrefix(mapping.getColumn(), columnPrefix);
  } else {
    //因為隻有1列,所以取得這一列的名字
    columnName = rsw.getColumnNames().get(0);
  }
  final TypeHandler<?> typeHandler = rsw.getTypeHandler(resultType, columnName);
  return typeHandler.getResult(rsw.getResultSet(), columnName);
}
 
開發者ID:shurun19851206,項目名稱:mybaties,代碼行數:15,代碼來源:DefaultResultSetHandler.java

示例14: applyAutomaticMappings

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
private boolean applyAutomaticMappings(ResultSetWrapper rsw, ResultMap resultMap, MetaObject metaObject, String columnPrefix) throws SQLException {
  final List<String> unmappedColumnNames = rsw.getUnmappedColumnNames(resultMap, columnPrefix);
  boolean foundValues = false;
  for (String columnName : unmappedColumnNames) {
    String propertyName = columnName;
    if (columnPrefix != null && !columnPrefix.isEmpty()) {
      // When columnPrefix is specified,
      // ignore columns without the prefix.
      if (columnName.toUpperCase(Locale.ENGLISH).startsWith(columnPrefix)) {
        propertyName = columnName.substring(columnPrefix.length());
      } else {
        continue;
      }
    }
    final String property = metaObject.findProperty(propertyName, configuration.isMapUnderscoreToCamelCase());
    if (property != null && metaObject.hasSetter(property)) {
      final Class<?> propertyType = metaObject.getSetterType(property);
      if (typeHandlerRegistry.hasTypeHandler(propertyType)) {
        final TypeHandler<?> typeHandler = rsw.getTypeHandler(propertyType, columnName);
        final Object value = typeHandler.getResult(rsw.getResultSet(), columnName);
        // issue #377, call setter on nulls
        if (value != null || configuration.isCallSettersOnNulls()) {
          if (value != null || !propertyType.isPrimitive()) {
            metaObject.setValue(property, value);
          }
          foundValues = true;
        }
      }
    }
  }
  return foundValues;
}
 
開發者ID:toulezu,項目名稱:play,代碼行數:33,代碼來源:DefaultResultSetHandler.java

示例15: getPropertyMappingValue

import org.apache.ibatis.type.TypeHandler; //導入方法依賴的package包/類
protected Object getPropertyMappingValue(ResultSet rs, MetaObject metaResultObject, ResultMapping propertyMapping, ResultLoaderMap lazyLoader, String columnPrefix) throws SQLException {
  final TypeHandler<?> typeHandler = propertyMapping.getTypeHandler();
  if (propertyMapping.getNestedQueryId() != null) {
    return getNestedQueryMappingValue(rs, metaResultObject, propertyMapping, lazyLoader, columnPrefix);
  } else if (typeHandler != null) {
    final String column = prependPrefix(propertyMapping.getColumn(), columnPrefix);
    return typeHandler.getResult(rs, column);
  }
  return null;
}
 
開發者ID:youngor,項目名稱:openclouddb,代碼行數:11,代碼來源:FastResultSetHandler.java


注:本文中的org.apache.ibatis.type.TypeHandler.getResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。