Search in sources :

Example 1 with DynamicContext

use of org.apache.ibatis.scripting.xmltags.DynamicContext in project qiuyj-code by qiuyuanjun.

the class ReturnValueWrapper method generateSqlSource.

/**
 * 生成对应的SqlSource,这里仅仅会生成DynamicSqlSource和StaticSqlSource
 */
public SqlSource generateSqlSource(Configuration configuration) {
    if (Objects.isNull(sqlNode)) {
        throw new IllegalArgumentException("SqlNode can not be null");
    } else {
        SqlSource sqlSource;
        if (generateStaticSqlSource) {
            DynamicContext context = new DynamicContext(configuration, null);
            sqlNode.apply(context);
            sqlSource = new StaticSqlSource(configuration, context.getSql(), parameterMappings);
        } else {
            sqlSource = new DynamicSqlSource(configuration, sqlNode);
        }
        return new MapperSqlSource(sqlSource);
    }
}
Also used : StaticSqlSource(org.apache.ibatis.builder.StaticSqlSource) DynamicSqlSource(org.apache.ibatis.scripting.xmltags.DynamicSqlSource) MapperSqlSource(com.qiuyj.mybatis.MapperSqlSource) SqlSource(org.apache.ibatis.mapping.SqlSource) DynamicSqlSource(org.apache.ibatis.scripting.xmltags.DynamicSqlSource) MapperSqlSource(com.qiuyj.mybatis.MapperSqlSource) StaticSqlSource(org.apache.ibatis.builder.StaticSqlSource) DynamicContext(org.apache.ibatis.scripting.xmltags.DynamicContext)

Example 2 with DynamicContext

use of org.apache.ibatis.scripting.xmltags.DynamicContext in project mybatis-3 by mybatis.

the class RawSqlSource method getSql.

private static String getSql(Configuration configuration, SqlNode rootSqlNode) {
    DynamicContext context = new DynamicContext(configuration, null);
    rootSqlNode.apply(context);
    return context.getSql();
}
Also used : DynamicContext(org.apache.ibatis.scripting.xmltags.DynamicContext)

Aggregations

DynamicContext (org.apache.ibatis.scripting.xmltags.DynamicContext)2 MapperSqlSource (com.qiuyj.mybatis.MapperSqlSource)1 StaticSqlSource (org.apache.ibatis.builder.StaticSqlSource)1 SqlSource (org.apache.ibatis.mapping.SqlSource)1 DynamicSqlSource (org.apache.ibatis.scripting.xmltags.DynamicSqlSource)1