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


Java BoundSql.setAdditionalParameter方法代碼示例

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


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

示例1: getBoundSql

import org.apache.ibatis.mapping.BoundSql; //導入方法依賴的package包/類
public BoundSql getBoundSql(Object parameterObject) {
    DynamicContext context = new DynamicContext(configuration, parameterObject);
    rootSqlNode.apply(context);
    SqlSourceBuilder sqlSourceParser = new SqlSourceBuilder(configuration);
    Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass();
    SqlSource sqlSource = sqlSourceParser.parse(context.getSql(), parameterType, context.getBindings());
    if (count) {
        sqlSource = getCountSqlSource(configuration, sqlSource, parameterObject);
    } else {
        sqlSource = getPageSqlSource(configuration, sqlSource, parameterObject);
    }
    BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
    // 設置條件參數
    for (Map.Entry<String, Object> entry : context.getBindings().entrySet()) {
        boundSql.setAdditionalParameter(entry.getKey(), entry.getValue());
    }
    return boundSql;
}
 
開發者ID:PekingGo,項目名稱:ipayquery,代碼行數:19,代碼來源:SqlUtil.java

示例2: getBoundSql

import org.apache.ibatis.mapping.BoundSql; //導入方法依賴的package包/類
@Override
public BoundSql getBoundSql(Object parameterObject) {
  Map<String, Object> bindings = createBindings(parameterObject, configuration);
  VelocityContext context = new VelocityContext(bindings);
  StringWriter sw = new StringWriter();
  script.merge(context, sw);
  VelocitySqlSourceBuilder sqlSourceParser = new VelocitySqlSourceBuilder(configuration);
  Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass();
  SqlSource sqlSource = sqlSourceParser.parse(sw.toString(), parameterType);
  BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
  for (Map.Entry<String, Object> entry : bindings.entrySet()) {
    boundSql.setAdditionalParameter(entry.getKey(), entry.getValue());
  }
  return boundSql;

}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:17,代碼來源:VelocitySqlSource.java

示例3: processIntercept

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

示例4: copyFromBoundSql

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

示例5: copyFromBoundSql

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

示例6: getBoundSql

import org.apache.ibatis.mapping.BoundSql; //導入方法依賴的package包/類
@Override
public BoundSql getBoundSql(Object parameterObject) {
  DynamicContext context = new DynamicContext(configuration, parameterObject);
  rootSqlNode.apply(context);
  SqlSourceBuilder sqlSourceParser = new SqlSourceBuilder(configuration);
  Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass();
  SqlSource sqlSource = sqlSourceParser.parse(context.getSql(), parameterType, context.getBindings());
  BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
  for (Map.Entry<String, Object> entry : context.getBindings().entrySet()) {
    boundSql.setAdditionalParameter(entry.getKey(), entry.getValue());
  }
  return boundSql;
}
 
開發者ID:yuexiahandao,項目名稱:MybatisCode,代碼行數:14,代碼來源:DynamicSqlSource.java

示例7: copyFromBoundSql

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

示例8: processIntercept

import org.apache.ibatis.mapping.BoundSql; //導入方法依賴的package包/類
void processIntercept(final Object[] queryArgs) throws Exception
{
	/*
	// 以下代碼可根據數據源動態加載方言,用於多數據源的情況下
	Dialect dialect = this.dialect;
	String str = DynamicDataSource.getDbType();
	if(!str.equals("1"))
	{
		String dialectClass = this.properties.getProperty(str);
		try
		{
			System.out.println("dbType是" + str + ",加載動態方言:" + dialectClass);
			dialect = (Dialect) Class.forName(dialectClass).newInstance();
		}
		catch (Exception e)
		{
			throw new RuntimeException("無法初始化方言:" + dialectClass, e);
		}
	}
	*/
	final RowBounds rowBounds = (RowBounds) queryArgs[ROWBOUNDS_INDEX];
	int offset = rowBounds.getOffset();
	int limit = rowBounds.getLimit();
	if (dialect.supportsLimitOffset() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT))
	{
		MappedStatement ms = (MappedStatement) queryArgs[MAPPED_STATEMENT_INDEX];
		Object parameter = queryArgs[PARAMETER_INDEX];
		BoundSql boundSql = ms.getBoundSql(parameter);
		String sql = boundSql.getSql().trim();
		
		sql = dialect.getLimitString(sql, offset, limit);
		offset = RowBounds.NO_ROW_OFFSET;
		
		limit = RowBounds.NO_ROW_LIMIT;
		queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset, limit);
		BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql, boundSql.getParameterMappings(), boundSql.getParameterObject());
		String prop;
		for(ParameterMapping p : boundSql.getParameterMappings())
		{
			prop = p.getProperty();
			if(boundSql.hasAdditionalParameter(prop))
			{
				newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
			}
		}
		MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql));
		queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
	}
}
 
開發者ID:skeychen,項目名稱:dswork,代碼行數:50,代碼來源:OffsetLimitInterceptor.java

示例9: getBoundSql

import org.apache.ibatis.mapping.BoundSql; //導入方法依賴的package包/類
public BoundSql getBoundSql(Object parameterObject) {

        List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();

        Map<String, Object> context = new HashMap<String, Object>();
        context.put("_configuration", configuration);
        context.put("_parameterMappings", parameterMappings);

        context.put("_databaseId", configuration.getDatabaseId());
        context.put("_parameter", parameterObject);
        Map<String, Object> params = new HashMap<String, Object>();
        context.put("_params", params);


        String sql = BeetlFacade.apply(script, context);

        BoundSql boundSql = new BoundSql(configuration, sql, parameterMappings, parameterObject);

        for (Map.Entry<String, Object> entry : params.entrySet()) {
            boundSql.setAdditionalParameter(entry.getKey(), entry.getValue());
        }


        return boundSql;
    }
 
開發者ID:hatunet,項目名稱:mybatis-beetl-scripting,代碼行數:26,代碼來源:BeetlSqlSource.java


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