本文整理汇总了Java中org.apache.ibatis.mapping.SqlSource.getBoundSql方法的典型用法代码示例。如果您正苦于以下问题:Java SqlSource.getBoundSql方法的具体用法?Java SqlSource.getBoundSql怎么用?Java SqlSource.getBoundSql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.mapping.SqlSource
的用法示例。
在下文中一共展示了SqlSource.getBoundSql方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBoundSql
import org.apache.ibatis.mapping.SqlSource; //导入方法依赖的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.SqlSource; //导入方法依赖的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: getBoundSql
import org.apache.ibatis.mapping.SqlSource; //导入方法依赖的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;
}
示例4: getBoundSql
import org.apache.ibatis.mapping.SqlSource; //导入方法依赖的package包/类
@Override
public BoundSql getBoundSql(Object parameterObject) {
SqlSource sqlSource = createSqlSource(parameterObject);
return sqlSource.getBoundSql(parameterObject);
}
示例5: getPageSqlSource
import org.apache.ibatis.mapping.SqlSource; //导入方法依赖的package包/类
/**
* 获取分页的sqlSource
*
* @param configuration
* @param sqlSource
* @return
*/
private SqlSource getPageSqlSource(Configuration configuration, SqlSource sqlSource, Object parameterObject) {
BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
return new StaticSqlSource(configuration, sqlParser.getPageSql(boundSql.getSql()), getPageParameterMapping(configuration, boundSql));
}
示例6: getCountSqlSource
import org.apache.ibatis.mapping.SqlSource; //导入方法依赖的package包/类
/**
* 获取count的sqlSource
*
* @param sqlSource
* @return
*/
private SqlSource getCountSqlSource(Configuration configuration, SqlSource sqlSource, Object parameterObject) {
BoundSql boundSql = sqlSource.getBoundSql(parameterObject);
return new StaticSqlSource(configuration, sqlParser.getCountSql(boundSql.getSql()), boundSql.getParameterMappings());
}