本文整理匯總了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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}