Search in sources :

Example 1 with RawSqlSource

use of org.apache.ibatis.scripting.defaults.RawSqlSource in project mybatis-3 by mybatis.

the class XMLScriptBuilder method parseScriptNode.

public SqlSource parseScriptNode() {
    List<SqlNode> contents = parseDynamicTags(context);
    MixedSqlNode rootSqlNode = new MixedSqlNode(contents);
    SqlSource sqlSource = null;
    if (isDynamic) {
        sqlSource = new DynamicSqlSource(configuration, rootSqlNode);
    } else {
        sqlSource = new RawSqlSource(configuration, rootSqlNode, parameterType);
    }
    return sqlSource;
}
Also used : SqlSource(org.apache.ibatis.mapping.SqlSource) RawSqlSource(org.apache.ibatis.scripting.defaults.RawSqlSource) RawSqlSource(org.apache.ibatis.scripting.defaults.RawSqlSource)

Example 2 with RawSqlSource

use of org.apache.ibatis.scripting.defaults.RawSqlSource in project mybatis-3 by mybatis.

the class XMLLanguageDriver method createSqlSource.

@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
    // issue #3
    if (script.startsWith("<script>")) {
        XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
        return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
    } else {
        // issue #127
        script = PropertyParser.parse(script, configuration.getVariables());
        TextSqlNode textSqlNode = new TextSqlNode(script);
        if (textSqlNode.isDynamic()) {
            return new DynamicSqlSource(configuration, textSqlNode);
        } else {
            return new RawSqlSource(configuration, script, parameterType);
        }
    }
}
Also used : XMLMapperEntityResolver(org.apache.ibatis.builder.xml.XMLMapperEntityResolver) XPathParser(org.apache.ibatis.parsing.XPathParser) RawSqlSource(org.apache.ibatis.scripting.defaults.RawSqlSource)

Aggregations

RawSqlSource (org.apache.ibatis.scripting.defaults.RawSqlSource)2 XMLMapperEntityResolver (org.apache.ibatis.builder.xml.XMLMapperEntityResolver)1 SqlSource (org.apache.ibatis.mapping.SqlSource)1 XPathParser (org.apache.ibatis.parsing.XPathParser)1