View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.scripting;
17  
18  import org.apache.ibatis.executor.parameter.ParameterHandler;
19  import org.apache.ibatis.mapping.BoundSql;
20  import org.apache.ibatis.mapping.MappedStatement;
21  import org.apache.ibatis.mapping.SqlSource;
22  import org.apache.ibatis.parsing.XNode;
23  import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
24  import org.apache.ibatis.session.Configuration;
25  
26  public interface LanguageDriver {
27  
28    /**
29     * Creates a {@link ParameterHandler} that passes the actual parameters to the the JDBC statement.
30     *
31     * @author Frank D. Martinez [mnesarco]
32     *
33     * @param mappedStatement
34     *          The mapped statement that is being executed
35     * @param parameterObject
36     *          The input parameter object (can be null)
37     * @param boundSql
38     *          The resulting SQL once the dynamic language has been executed.
39     *
40     * @return the parameter handler
41     *
42     * @see DefaultParameterHandler
43     */
44    ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject, BoundSql boundSql);
45  
46    /**
47     * Creates an {@link SqlSource} that will hold the statement read from a mapper xml file. It is called during startup,
48     * when the mapped statement is read from a class or an xml file.
49     *
50     * @param configuration
51     *          The MyBatis configuration
52     * @param script
53     *          XNode parsed from a XML file
54     * @param parameterType
55     *          input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be
56     *          null.
57     *
58     * @return the sql source
59     */
60    SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType);
61  
62    /**
63     * Creates an {@link SqlSource} that will hold the statement read from an annotation. It is called during startup,
64     * when the mapped statement is read from a class or an xml file.
65     *
66     * @param configuration
67     *          The MyBatis configuration
68     * @param script
69     *          The content of the annotation
70     * @param parameterType
71     *          input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be
72     *          null.
73     *
74     * @return the sql source
75     */
76    SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType);
77  
78  }