Search in sources :

Example 1 with MapperSqlSource

use of com.qiuyj.mybatis.MapperSqlSource 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)

Aggregations

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