org.apache.ibatis.mapping.BoundSql.getParameterMappings()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(12.3k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中org.apache.ibatis.mapping.BoundSql.getParameterMappings()方法的一些代码示例,展示了BoundSql.getParameterMappings()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BoundSql.getParameterMappings()方法的具体详情如下:
包路径:org.apache.ibatis.mapping.BoundSql
类名称:BoundSql
方法名:getParameterMappings

BoundSql.getParameterMappings介绍

暂无

代码示例

代码示例来源:origin: pagehelper/Mybatis-PageHelper

protected void handleParameter(BoundSql boundSql, MappedStatement ms){
    if (boundSql.getParameterMappings() != null) {
      List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>(boundSql.getParameterMappings());
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
      MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
      metaObject.setValue("parameterMappings", newParameterMappings);
    }
  }
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

if (boundSql.getParameterMappings() != null && boundSql.getParameterMappings().size() > 0) {
  for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
    String name = parameterMapping.getProperty();
    if (!name.equals(PAGEPARAMETER_FIRST)

代码示例来源:origin: pagehelper/Mybatis-PageHelper

@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
  paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
  paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
  //处理pageKey
  pageKey.update(page.getStartRow());
  pageKey.update(page.getPageSize());
  //处理参数配置
  if (boundSql.getParameterMappings() != null) {
    List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>();
    if (page.getStartRow() > 0) {
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
    }
    if (page.getPageSize() > 0) {
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
    }
    newParameterMappings.addAll(boundSql.getParameterMappings());
    MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
    metaObject.setValue("parameterMappings", newParameterMappings);
  }
  return paramMap;
}

代码示例来源:origin: a466350665/smart

countStmt = connection.prepareStatement(countSql);
BoundSql countBS = new BoundSql(mappedStatement.getConfiguration(), countSql,
    boundSql.getParameterMappings(), boundSql.getParameterObject());
setParameters(countStmt, mappedStatement, countBS, boundSql.getParameterObject());
rs = countStmt.executeQuery();

代码示例来源:origin: pagehelper/Mybatis-PageHelper

BoundSql countBoundSql = new BoundSql(countMs.getConfiguration(), countSql, boundSql.getParameterMappings(), parameter);

代码示例来源:origin: pagehelper/Mybatis-PageHelper

@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
  paramMap.put(PAGEPARAMETER_FIRST, page.getPageSize());
  paramMap.put(PAGEPARAMETER_SECOND, page.getStartRow());
  //处理pageKey
  pageKey.update(page.getPageSize());
  pageKey.update(page.getStartRow());
  //处理参数配置
  if (boundSql.getParameterMappings() != null) {
    List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>(boundSql.getParameterMappings());
    if (page.getPageSize() > 0) {
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
    }
    if (page.getStartRow() > 0) {
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
    }
    MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
    metaObject.setValue("parameterMappings", newParameterMappings);
  }
  return paramMap;
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

@Override
public Object processPageParameter(MappedStatement ms, Map<String, Object> paramMap, Page page, BoundSql boundSql, CacheKey pageKey) {
  paramMap.put(PAGEPARAMETER_FIRST, page.getStartRow());
  paramMap.put(PAGEPARAMETER_SECOND, page.getPageSize());
  //处理pageKey
  pageKey.update(page.getStartRow());
  pageKey.update(page.getPageSize());
  //处理参数配置
  if (boundSql.getParameterMappings() != null) {
    List<ParameterMapping> newParameterMappings = new ArrayList<ParameterMapping>(boundSql.getParameterMappings());
    if (page.getStartRow() == 0) {
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
    } else {
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_FIRST, Integer.class).build());
      newParameterMappings.add(new ParameterMapping.Builder(ms.getConfiguration(), PAGEPARAMETER_SECOND, Integer.class).build());
    }
    MetaObject metaObject = MetaObjectUtil.forObject(boundSql);
    metaObject.setValue("parameterMappings", newParameterMappings);
  }
  return paramMap;
}

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

private static String showSql(Configuration configuration, BoundSql boundSql) {
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();

代码示例来源:origin: pagehelper/Mybatis-PageHelper

BoundSql pageBoundSql = new BoundSql(ms.getConfiguration(), pageSql, boundSql.getParameterMappings(), parameter);

代码示例来源:origin: baomidou/mybatis-plus

public void setParameters(PreparedStatement ps) {
  ErrorContext.instance().activity("setting parameters").object(mappedStatement.getParameterMap().getId());
  List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
  if (parameterMappings != null) {
    for (int i = 0; i < parameterMappings.size(); i++) {

代码示例来源:origin: baomidou/mybatis-plus

DialectModel model = DialectFactory.buildPaginationSql(page, buildSql, dbType, dialectClazz);
Configuration configuration = mappedStatement.getConfiguration();
List<ParameterMapping> mappings = new ArrayList<>(boundSql.getParameterMappings());
Map<String, Object> additionalParameters = (Map<String, Object>) metaObject.getValue("delegate.boundSql.additionalParameters");
model.consumers(mappings, configuration, additionalParameters);

代码示例来源:origin: camunda/camunda-bpm-platform

public BoundSql getBoundSql(Object parameterObject) {
 BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
 List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
 if (parameterMappings == null || parameterMappings.isEmpty()) {
  boundSql = new BoundSql(configuration, boundSql.getSql(), parameterMap.getParameterMappings(), parameterObject);
 }
 // check for nested result maps in parameter mappings (issue #30)
 for (ParameterMapping pm : boundSql.getParameterMappings()) {
  String rmId = pm.getResultMapId();
  if (rmId != null) {
   ResultMap rm = configuration.getResultMap(rmId);
   if (rm != null) {
    hasNestedResultMaps |= rm.hasNestedResultMaps();
   }
  }
 }
 return boundSql;
}

代码示例来源:origin: org.mybatis/mybatis

public BoundSql getBoundSql(Object parameterObject) {
 BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
 List<ParameterMapping> parameterMappings = boundSql.getParameterMappings();
 if (parameterMappings == null || parameterMappings.isEmpty()) {
  boundSql = new BoundSql(configuration, boundSql.getSql(), parameterMap.getParameterMappings(), parameterObject);
 }
 // check for nested result maps in parameter mappings (issue #30)
 for (ParameterMapping pm : boundSql.getParameterMappings()) {
  String rmId = pm.getResultMapId();
  if (rmId != null) {
   ResultMap rm = configuration.getResultMap(rmId);
   if (rm != null) {
    hasNestedResultMaps |= rm.hasNestedResultMaps();
   }
  }
 }
 return boundSql;
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void ensureNoOutParams(MappedStatement ms, Object parameter, BoundSql boundSql) {
 if (ms.getStatementType() == StatementType.CALLABLE) {
  for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
   if (parameterMapping.getMode() != ParameterMode.IN) {
    throw new ExecutorException("Caching stored procedures with OUT params is not supported.  Please configure useCache=false in " + ms.getId() + " statement.");
   }
  }
 }
}

代码示例来源:origin: org.mybatis/mybatis

private void ensureNoOutParams(MappedStatement ms, BoundSql boundSql) {
 if (ms.getStatementType() == StatementType.CALLABLE) {
  for (ParameterMapping parameterMapping : boundSql.getParameterMappings()) {
   if (parameterMapping.getMode() != ParameterMode.IN) {
    throw new ExecutorException("Caching stored procedures with OUT params is not supported.  Please configure useCache=false in " + ms.getId() + " statement.");
   }
  }
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
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();
    metaParam.setValue(parameterMapping.getProperty(), typeHandler.getResult(cs, i + 1));
   }
  }
 }
}

代码示例来源:origin: org.mybatis/mybatis

@Override
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();
    metaParam.setValue(parameterMapping.getProperty(), typeHandler.getResult(cs, i + 1));
   }
  }
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

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);
    }
   }
  }
 }
}

代码示例来源:origin: org.mybatis/mybatis

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);
    }
   }
  }
 }
}

代码示例来源:origin: Meituan-Dianping/Zebra

private Object queryLimit(Invocation invocation, Object[] args, MappedStatement ms, BoundSql boundSql, RowBounds rb)
    throws InvocationTargetException, IllegalAccessException {
  String limitSql = dialect.getLimitSql(boundSql.getSql(), rb.getOffset(), rb.getLimit());
  BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), limitSql, boundSql.getParameterMappings(),
      boundSql.getParameterObject());
  MetaObject mo = (MetaObject) ReflectionUtils.getFieldValue(boundSql, "metaParameters");
  ReflectionUtils.setFieldValue(newBoundSql, "metaParameters", mo);
  args[0] = buildMappedStatement(ms, new SqlSourceWrapper(newBoundSql), ms.getId() + "_LIMIT",
      ms.getResultMaps());
  args[2] = new RowBounds();
  args[3] = null;
  try {
    DaoContextHolder.setSqlName(buildDaoName(ms.getId()) + "_LIMIT");
    return invocation.proceed();
  } finally {
    DaoContextHolder.clearSqlName();
  }
}

相关文章