Example usage for org.apache.ibatis.scripting.xmltags SqlNode apply

List of usage examples for org.apache.ibatis.scripting.xmltags SqlNode apply

Introduction

In this page you can find the example usage for org.apache.ibatis.scripting.xmltags SqlNode apply.

Prototype

boolean apply(DynamicContext context);

Source Link

Usage

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);
    String countextSql = context.getSql();
    // ?/*from   w w  w .  ja v  a  2s.c  o m*/
    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;
}