List of usage examples for org.apache.ibatis.scripting.xmltags DynamicContext getSql
public String getSql()
From source file:cn.com.bricks.mybatis.rbac.DynamicRbacInterceptor.java
protected BoundSql getBoundSql(Configuration configuration, Object parameterObject, SqlNode sqlNode) throws SQLException { DynamicContext context = new DynamicContext(configuration, parameterObject); sqlNode.apply(context);/*from w ww . j a va 2 s . c o m*/ String countextSql = context.getSql(); // ? SqlSourceBuilder sqlSourceParser = new SqlSourceBuilder(configuration); Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass(); String sql = modifySqlAddUserRole(countextSql, parameterObject); SqlSource sqlSource = sqlSourceParser.parse(sql, 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; }
From source file:com.appleframework.orm.mybatis.pagehelper.sqlsource.PageDynamicSqlSource.java
License:Open Source License
@Override protected BoundSql getDefaultBoundSql(Object parameterObject) { DynamicContext context = new DynamicContext(configuration, parameterObject); rootSqlNode.apply(context);/*from ww w .ja v a 2s .c om*/ SqlSourceBuilder sqlSourceParser = new SqlSourceBuilder(configuration); Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass(); SqlSource sqlSource = sqlSourceParser.parse(context.getSql(), parameterType, context.getBindings()); sqlSource = new OrderByStaticSqlSource((StaticSqlSource) sqlSource); BoundSql boundSql = sqlSource.getBoundSql(parameterObject); //?? for (Map.Entry<String, Object> entry : context.getBindings().entrySet()) { boundSql.setAdditionalParameter(entry.getKey(), entry.getValue()); } return boundSql; }
From source file:com.appleframework.orm.mybatis.pagehelper.sqlsource.PageDynamicSqlSource.java
License:Open Source License
@Override protected BoundSql getCountBoundSql(Object parameterObject) { DynamicContext context = new DynamicContext(configuration, parameterObject); rootSqlNode.apply(context);// w w w .j av a2 s . co m 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); sqlSource = new StaticSqlSource(configuration, localParser.get().getCountSql(boundSql.getSql()), boundSql.getParameterMappings()); boundSql = sqlSource.getBoundSql(parameterObject); //?? for (Map.Entry<String, Object> entry : context.getBindings().entrySet()) { boundSql.setAdditionalParameter(entry.getKey(), entry.getValue()); } return boundSql; }
From source file:com.appleframework.orm.mybatis.pagehelper.sqlsource.PageDynamicSqlSource.java
License:Open Source License
@SuppressWarnings("rawtypes") @Override/*from w w w .j a va 2 s . co m*/ protected BoundSql getPageBoundSql(Object parameterObject) { DynamicContext context; //??parameterObject??? //??Map?KEY //bug#25:http://git.oschina.net/free/Mybatis_PageHelper/issues/25 if (parameterObject != null && parameterObject instanceof Map && ((Map) parameterObject).containsKey(ORIGINAL_PARAMETER_OBJECT)) { context = new DynamicContext(configuration, ((Map) parameterObject).get(ORIGINAL_PARAMETER_OBJECT)); } else { 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()); sqlSource = new OrderByStaticSqlSource((StaticSqlSource) sqlSource); BoundSql boundSql = sqlSource.getBoundSql(parameterObject); sqlSource = new StaticSqlSource(configuration, localParser.get().getPageSql(boundSql.getSql()), localParser.get().getPageParameterMapping(configuration, boundSql)); boundSql = sqlSource.getBoundSql(parameterObject); //?? for (Map.Entry<String, Object> entry : context.getBindings().entrySet()) { boundSql.setAdditionalParameter(entry.getKey(), entry.getValue()); } return boundSql; }
From source file:com.icfcc.db.pagehelper.sqlsource.PageDynamicSqlSource.java
License:Open Source License
@Override protected BoundSql getCountBoundSql(Object parameterObject) { DynamicContext context = new DynamicContext(configuration, parameterObject); rootSqlNode.apply(context);//from w w w.j a va 2s . c o m 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); sqlSource = new StaticSqlSource(configuration, parser.getCountSql(boundSql.getSql()), boundSql.getParameterMappings()); boundSql = sqlSource.getBoundSql(parameterObject); //?? for (Map.Entry<String, Object> entry : context.getBindings().entrySet()) { boundSql.setAdditionalParameter(entry.getKey(), entry.getValue()); } return boundSql; }
From source file:com.icfcc.db.pagehelper.sqlsource.PageDynamicSqlSource.java
License:Open Source License
@Override protected BoundSql getPageBoundSql(Object parameterObject) { DynamicContext context; //??parameterObject??? //??Map?KEY//w ww. j a v a 2 s. c o m //bug#25:http://git.oschina.net/free/Mybatis_PageHelper/issues/25 if (parameterObject != null && parameterObject instanceof Map && ((Map) parameterObject).containsKey(ORIGINAL_PARAMETER_OBJECT)) { context = new DynamicContext(configuration, ((Map) parameterObject).get(ORIGINAL_PARAMETER_OBJECT)); } else { 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()); sqlSource = new OrderByStaticSqlSource((StaticSqlSource) sqlSource); BoundSql boundSql = sqlSource.getBoundSql(parameterObject); sqlSource = new StaticSqlSource(configuration, parser.getPageSql(boundSql.getSql()), parser.getPageParameterMapping(configuration, boundSql)); boundSql = sqlSource.getBoundSql(parameterObject); //?? for (Map.Entry<String, Object> entry : context.getBindings().entrySet()) { boundSql.setAdditionalParameter(entry.getKey(), entry.getValue()); } return boundSql; }
From source file:com.linju.framework.pager.sqlsource.PageDynamicSqlSource.java
License:Open Source License
public BoundSql getBoundSql(Object parameterObject) { DynamicContext context; //??parameterObject??? //??Map?KEY/* ww w .jav a 2s. c om*/ //bug#25:http://git.oschina.net/free/Mybatis_PageHelper/issues/25 if (parameterObject != null && parameterObject instanceof Map && ((Map) parameterObject).containsKey(ORIGINAL_PARAMETER_OBJECT)) { context = new DynamicContext(configuration, ((Map) parameterObject).get(ORIGINAL_PARAMETER_OBJECT)); } else { 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 = msUtils.getStaticCountSqlSource(configuration, sqlSource, parameterObject); } else { sqlSource = msUtils.getStaticPageSqlSource(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; }
From source file:org.fire.platform.common.page.sqlsource.PageDynamicSqlSource.java
License:Open Source License
@SuppressWarnings("rawtypes") public BoundSql getBoundSql(Object parameterObject) { DynamicContext context; //??parameterObject??? //??Map?KEY//www . ja v a 2 s . com //bug#25:http://git.oschina.net/free/Mybatis_PageHelper/issues/25 if (parameterObject != null && parameterObject instanceof Map && ((Map) parameterObject).containsKey(ORIGINAL_PARAMETER_OBJECT)) { context = new DynamicContext(configuration, ((Map) parameterObject).get(ORIGINAL_PARAMETER_OBJECT)); } else { 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 = msUtils.getStaticCountSqlSource(configuration, sqlSource, parameterObject); } else { sqlSource = msUtils.getStaticPageSqlSource(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; }