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


Java ParameterMapping.getProperty方法代码示例

本文整理汇总了Java中org.apache.ibatis.mapping.ParameterMapping.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ParameterMapping.getProperty方法的具体用法?Java ParameterMapping.getProperty怎么用?Java ParameterMapping.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.mapping.ParameterMapping的用法示例。


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

示例1: handleLocallyCachedOutputParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
private void handleLocallyCachedOutputParameters(MappedStatement ms, CacheKey key, Object parameter, BoundSql boundSql) {
  if (ms.getStatementType() == StatementType.CALLABLE) {
    final Object cachedParameter = localOutputParameterCache.getObject(key);
    if (cachedParameter != null && parameter != null) {
      final MetaObject metaCachedParameter = configuration.newMetaObject(cachedParameter);
      final MetaObject metaParameter = configuration.newMetaObject(parameter);
      for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
        if (parameterMapping.getMode() != ParameterMode.IN) {
          final String parameterName = parameterMapping.getProperty();
          final Object cachedValue = metaCachedParameter.getValue(parameterName);
          metaParameter.setValue(parameterName, cachedValue);
        }
      }
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:BaseExecutor.java

示例2: registerOutputParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
private void registerOutputParameters(CallableStatement cs) throws SQLException {
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  for (int i = 0, n = parameterMappings.size(); i < n; i++) {
    ParameterMapping parameterMapping = parameterMappings.get(i);
    if (parameterMapping.getMode() == ParameterMode.OUT || parameterMapping.getMode() == ParameterMode.INOUT) {
      if (null == parameterMapping.getJdbcType()) {
        throw new ExecutorException("The JDBC Type must be specified for output parameter.  Parameter: " + parameterMapping.getProperty());
      } else {
        if (parameterMapping.getNumericScale() != null && (parameterMapping.getJdbcType() == JdbcType.NUMERIC || parameterMapping.getJdbcType() == JdbcType.DECIMAL)) {
          cs.registerOutParameter(i + 1, parameterMapping.getJdbcType().TYPE_CODE, parameterMapping.getNumericScale());
        } else {
          if (parameterMapping.getJdbcTypeName() == null) {
            cs.registerOutParameter(i + 1, parameterMapping.getJdbcType().TYPE_CODE);
          } else {
            cs.registerOutParameter(i + 1, parameterMapping.getJdbcType().TYPE_CODE, parameterMapping.getJdbcTypeName());
          }
        }
      }
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:22,代码来源:CallableStatementHandler.java

示例3: handleLocallyCachedOutputParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
private void handleLocallyCachedOutputParameters(MappedStatement ms, CacheKey key, Object parameter, BoundSql boundSql) {
  //处理存储过程的OUT参数
  if (ms.getStatementType() == StatementType.CALLABLE) {
    final Object cachedParameter = localOutputParameterCache.getObject(key);
    if (cachedParameter != null && parameter != null) {
      final MetaObject metaCachedParameter = configuration.newMetaObject(cachedParameter);
      final MetaObject metaParameter = configuration.newMetaObject(parameter);
      for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
        if (parameterMapping.getMode() != ParameterMode.IN) {
          final String parameterName = parameterMapping.getProperty();
          final Object cachedValue = metaCachedParameter.getValue(parameterName);
          metaParameter.setValue(parameterName, cachedValue);
        }
      }
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:18,代码来源:BaseExecutor.java

示例4: registerOutputParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
private void registerOutputParameters(CallableStatement cs) throws SQLException {
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  for (int i = 0, n = parameterMappings.size(); i < n; i++) {
    ParameterMapping parameterMapping = parameterMappings.get(i);
    //只处理OUT|INOUT
    if (parameterMapping.getMode() == ParameterMode.OUT || parameterMapping.getMode() == ParameterMode.INOUT) {
      if (null == parameterMapping.getJdbcType()) {
        throw new ExecutorException("The JDBC Type must be specified for output parameter.  Parameter: " + parameterMapping.getProperty());
      } else {
        if (parameterMapping.getNumericScale() != null && (parameterMapping.getJdbcType() == JdbcType.NUMERIC || parameterMapping.getJdbcType() == JdbcType.DECIMAL)) {
          cs.registerOutParameter(i + 1, parameterMapping.getJdbcType().TYPE_CODE, parameterMapping.getNumericScale());
        } else {
          //核心是调用CallableStatement.registerOutParameter
          if (parameterMapping.getJdbcTypeName() == null) {
            cs.registerOutParameter(i + 1, parameterMapping.getJdbcType().TYPE_CODE);
          } else {
            cs.registerOutParameter(i + 1, parameterMapping.getJdbcType().TYPE_CODE, parameterMapping.getJdbcTypeName());
          }
        }
      }
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:24,代码来源:CallableStatementHandler.java

示例5: handleOutputParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
public void handleOutputParameters(CallableStatement cs) throws SQLException {
  final Object parameterObject = parameterHandler.getParameterObject();
  final MetaObject metaParam = configuration.newMetaObject(parameterObject);
  final List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  for (int i = 0; i < parameterMappings.size(); i++) {
    final ParameterMapping parameterMapping = parameterMappings.get(i);
    if (parameterMapping.getMode() == ParameterMode.OUT || parameterMapping.getMode() == ParameterMode.INOUT) {
      if (ResultSet.class.equals(parameterMapping.getJavaType())) {
        handleRefCursorOutputParameter((ResultSet) cs.getObject(i + 1), parameterMapping, metaParam);
      } else {
        final TypeHandler<?> typeHandler = parameterMapping.getTypeHandler();
        if (typeHandler == null) {
          throw new ExecutorException("Type handler was null on parameter mapping for property '" + parameterMapping.getProperty() + "'.  " +
              "It was either not specified and/or could not be found for the javaType / jdbcType combination specified.");
        }
        metaParam.setValue(parameterMapping.getProperty(), typeHandler.getResult(cs, i + 1));
      }
    }
  }
}
 
开发者ID:youngor,项目名称:openclouddb,代码行数:21,代码来源:FastResultSetHandler.java

示例6: processIntercept

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
void processIntercept(final Object[] queryArgs) {
	MappedStatement ms = (MappedStatement) queryArgs[MAPPED_STATEMENT_INDEX];
	Object parameter = queryArgs[PARAMETER_INDEX];
	final RowBounds rowBounds = (RowBounds) queryArgs[ROWBOUNDS_INDEX];
	int offset = rowBounds.getOffset();
	int limit = rowBounds.getLimit();
	if (dialect.supportsLimit() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT)) {
		BoundSql boundSql = ms.getBoundSql(parameter);
		String sql = boundSql.getSql().trim();
		if (dialect.supportsLimitOffset()) {
			sql = dialect.getLimitString(sql, offset, limit);
			offset = RowBounds.NO_ROW_OFFSET;
		} else {
			sql = dialect.getLimitString(sql, 0, limit);
		}
		limit = RowBounds.NO_ROW_LIMIT;
		queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset, limit);
		BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql, boundSql.getParameterMappings(),
				boundSql.getParameterObject());
		for (ParameterMapping mapping : boundSql.getParameterMappings()) {
			String prop = mapping.getProperty();
			if (boundSql.hasAdditionalParameter(prop)) {
				newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
			}
		}
		MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql));
		queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
	}
}
 
开发者ID:yi-jun,项目名称:aaden-pay,代码行数:30,代码来源:PagePluging.java

示例7: getNamespaceSql

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
/**
 * 通过命名空间方式获取sql
 * @param session
 * @param namespace
 * @param params
 * @return
 */
public static String getNamespaceSql(SqlSession session, String namespace, Object params) {
    Configuration configuration = session.getConfiguration();
    MappedStatement mappedStatement = configuration.getMappedStatement(namespace);
    TypeHandlerRegistry typeHandlerRegistry = mappedStatement.getConfiguration().getTypeHandlerRegistry();
    BoundSql boundSql = mappedStatement.getBoundSql(params);
    List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
    String sql = boundSql.getSql();
    if (parameterMappings != null) {
        for (int i = 0; i < parameterMappings.size(); i++) {
            ParameterMapping parameterMapping = parameterMappings.get(i);
            if (parameterMapping.getMode() != ParameterMode.OUT) {
                Object value;
                String propertyName = parameterMapping.getProperty();
                if (boundSql.hasAdditionalParameter(propertyName)) {
                    value = boundSql.getAdditionalParameter(propertyName);
                } else if (params == null) {
                    value = null;
                } else if (typeHandlerRegistry.hasTypeHandler(params.getClass())) {
                    value = params;
                } else {
                    MetaObject metaObject = configuration.newMetaObject(params);
                    value = metaObject.getValue(propertyName);
                }
                JdbcType jdbcType = parameterMapping.getJdbcType();
                if (value == null && jdbcType == null) jdbcType = configuration.getJdbcTypeForNull();
                sql = replaceParameter(sql, value, jdbcType, parameterMapping.getJavaType());
            }
        }
    }
    return sql;
}
 
开发者ID:itfsw,项目名称:mybatis-generator-plugin,代码行数:39,代码来源:SqlHelper.java

示例8: setParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
public void setParameters(PreparedStatement ps) throws SQLException {
    ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId());
    List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
    if (parameterMappings != null) {
        MetaObject metaObject = parameterObject == null ? null : configuration.newMetaObject(parameterObject);
        for (int i = 0; i < parameterMappings.size(); i++) {
            ParameterMapping parameterMapping = parameterMappings.get(i);
            if (parameterMapping.getMode() != ParameterMode.OUT) {
                Object value;
                String propertyName = parameterMapping.getProperty();
                if (boundSql.hasAdditionalParameter(propertyName)) { // issue #448 ask first for additional params
                    value = boundSql.getAdditionalParameter(propertyName);
                } else if (parameterObject == null) {
                    value = null;
                } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
                    value = parameterObject;
                } else {
                    value = metaObject == null ? null : metaObject.getValue(propertyName);
                }
                TypeHandler typeHandler = parameterMapping.getTypeHandler();
                if (typeHandler == null) {
                    throw new ExecutorException("There was no TypeHandler found for parameter " + propertyName + " of statement " + mappedStatement.getId());
                }
                JdbcType jdbcType = parameterMapping.getJdbcType();
                if (value == null && jdbcType == null) jdbcType = configuration.getJdbcTypeForNull();
                typeHandler.setParameter(ps, i + 1, value, jdbcType);
            }
        }
    }
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:31,代码来源:DefaultParameterHandler.java

示例9: copyFromBoundSql

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
private BoundSql copyFromBoundSql(MappedStatement ms, BoundSql boundSql,
		String sql, List<ParameterMapping> parameterMappings,Object parameter) {
	BoundSql newBoundSql = new BoundSql(ms.getConfiguration(),sql, parameterMappings, parameter);
	for (ParameterMapping mapping : boundSql.getParameterMappings()) {
	    String prop = mapping.getProperty();
	    if (boundSql.hasAdditionalParameter(prop)) {
	        newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
	    }
	}
	return newBoundSql;
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:12,代码来源:OffsetLimitInterceptor.java

示例10: copyFromBoundSql

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
private static BoundSql copyFromBoundSql(MappedStatement ms, BoundSql boundSql, String sql) {
    BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql, boundSql.getParameterMappings(), boundSql.getParameterObject());
    for (ParameterMapping mapping : boundSql.getParameterMappings()) {
        String prop = mapping.getProperty();
        if (boundSql.hasAdditionalParameter(prop)) {
            newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
        }
    }
    return newBoundSql;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:11,代码来源:PaginationHelper.java

示例11: createCacheKey

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
@Override
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
  if (closed) {
    throw new ExecutorException("Executor was closed.");
  }
  CacheKey cacheKey = new CacheKey();
  cacheKey.update(ms.getId());
  cacheKey.update(rowBounds.getOffset());
  cacheKey.update(rowBounds.getLimit());
  cacheKey.update(boundSql.getSql());
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  TypeHandlerRegistry typeHandlerRegistry = ms.getConfiguration().getTypeHandlerRegistry();
  // mimic DefaultParameterHandler logic
  for (ParameterMapping parameterMapping : parameterMappings) {
    if (parameterMapping.getMode() != ParameterMode.OUT) {
      Object value;
      String propertyName = parameterMapping.getProperty();
      if (boundSql.hasAdditionalParameter(propertyName)) {
        value = boundSql.getAdditionalParameter(propertyName);
      } else if (parameterObject == null) {
        value = null;
      } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
        value = parameterObject;
      } else {
        MetaObject metaObject = configuration.newMetaObject(parameterObject);
        value = metaObject.getValue(propertyName);
      }
      cacheKey.update(value);
    }
  }
  if (configuration.getEnvironment() != null) {
    // issue #176
    cacheKey.update(configuration.getEnvironment().getId());
  }
  return cacheKey;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:37,代码来源:BaseExecutor.java

示例12: setParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public void setParameters(PreparedStatement ps) throws SQLException {
    ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId());
    List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
    if (parameterMappings != null) {
        MetaObject metaObject = parameterObject == null ? null : configuration.newMetaObject(parameterObject);
        for (int i = 0; i < parameterMappings.size(); i++) {
            ParameterMapping parameterMapping = parameterMappings.get(i);
            if (parameterMapping.getMode() != ParameterMode.OUT) {
                Object value;
                String propertyName = parameterMapping.getProperty();
                if (boundSql.hasAdditionalParameter(propertyName)) { // issue #448 ask first for additional params
                    value = boundSql.getAdditionalParameter(propertyName);
                } else if (parameterObject == null) {
                    value = null;
                } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
                    value = parameterObject;
                } else {
                    value = metaObject == null ? null : metaObject.getValue(propertyName);
                }
                TypeHandler typeHandler = parameterMapping.getTypeHandler();
                if (typeHandler == null) {
                    throw new ExecutorException("There was no TypeHandler found for parameter " + propertyName + " of statement " + mappedStatement.getId());
                }
                JdbcType jdbcType = parameterMapping.getJdbcType();
                if (value == null && jdbcType == null) jdbcType = configuration.getJdbcTypeForNull();
                typeHandler.setParameter(ps, i + 1, value, jdbcType);
            }
        }
    }
}
 
开发者ID:codeWatching,项目名称:codePay,代码行数:32,代码来源:DefaultParameterHandler.java

示例13: copyFromBoundSql

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
private BoundSql copyFromBoundSql(MappedStatement ms, BoundSql boundSql,
		String sql) {
	BoundSql newBoundSql = new BoundSql(ms.getConfiguration(),sql, boundSql.getParameterMappings(), boundSql.getParameterObject());
	for (ParameterMapping mapping : boundSql.getParameterMappings()) {
	    String prop = mapping.getProperty();
	    if (boundSql.hasAdditionalParameter(prop)) {
	        newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
	    }
	}
	return newBoundSql;
}
 
开发者ID:codeWatching,项目名称:codePay,代码行数:12,代码来源:OffsetLimitInterceptor.java

示例14: createCacheKey

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
@Override
public CacheKey createCacheKey(MappedStatement ms, Object parameterObject, RowBounds rowBounds, BoundSql boundSql) {
  if (closed) {
    throw new ExecutorException("Executor was closed.");
  }
  CacheKey cacheKey = new CacheKey();
  cacheKey.update(ms.getId());
  cacheKey.update(Integer.valueOf(rowBounds.getOffset()));
  cacheKey.update(Integer.valueOf(rowBounds.getLimit()));
  cacheKey.update(boundSql.getSql());
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  TypeHandlerRegistry typeHandlerRegistry = ms.getConfiguration().getTypeHandlerRegistry();
  // mimic DefaultParameterHandler logic
  for (int i = 0; i < parameterMappings.size(); i++) {
    ParameterMapping parameterMapping = parameterMappings.get(i);
    if (parameterMapping.getMode() != ParameterMode.OUT) {
      Object value;
      String propertyName = parameterMapping.getProperty();
      if (boundSql.hasAdditionalParameter(propertyName)) {
        value = boundSql.getAdditionalParameter(propertyName);
      } else if (parameterObject == null) {
        value = null;
      } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
        value = parameterObject;
      } else {
        MetaObject metaObject = configuration.newMetaObject(parameterObject);
        value = metaObject.getValue(propertyName);
      }
      cacheKey.update(value);
    }
  }
  if (configuration.getEnvironment() != null) {
    // issue #176
    cacheKey.update(configuration.getEnvironment().getId());
  }
  return cacheKey;
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:38,代码来源:BaseExecutor.java

示例15: getParameters

import org.apache.ibatis.mapping.ParameterMapping; //导入方法依赖的package包/类
public static List getParameters(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql) {
    TypeHandlerRegistry typeHandlerRegistry = mappedStatement.getConfiguration().getTypeHandlerRegistry();

    List re = Lists.newArrayList();
    List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
    if (parameterMappings != null) {
        for (int i = 0; i < parameterMappings.size(); i++) {
            ParameterMapping parameterMapping = parameterMappings.get(i);
            if (parameterMapping.getMode() != ParameterMode.OUT) {
                Object value;
                String propertyName = parameterMapping.getProperty();
                if (boundSql.hasAdditionalParameter(propertyName)) {
                    value = boundSql.getAdditionalParameter(propertyName);
                } else if (parameterObject == null) {
                    value = null;
                } else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) {
                    value = parameterObject;
                } else {
                    MetaObject metaObject = mappedStatement.getConfiguration().newMetaObject(parameterObject);
                    value = metaObject.getValue(propertyName);
                }
                re.add(value);
            }
        }
    }
    return re;
}
 
开发者ID:maniaclee,项目名称:shardy,代码行数:28,代码来源:JdbcParameterHandler.java


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