• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / mybatis-3 / 2686

01 Feb 2025 09:55PM UTC coverage: 87.093% (-0.1%) from 87.217%
2686

Pull #3379

github

web-flow
Merge c97c5c598 into 3d71c862a
Pull Request #3379: Resolve type handler based on `java.lang.reflect.Type` instead of `Class` and respect runtime JDBC type

3825 of 4663 branches covered (82.03%)

515 of 579 new or added lines in 36 files covered. (88.95%)

28 existing lines in 6 files now uncovered.

9912 of 11381 relevant lines covered (87.09%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/src/main/java/org/apache/ibatis/scripting/xmltags/XMLLanguageDriver.java
1
/*
2
 *    Copyright 2009-2025 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.xmltags;
17

18
import org.apache.ibatis.builder.xml.XMLMapperEntityResolver;
19
import org.apache.ibatis.executor.parameter.ParameterHandler;
20
import org.apache.ibatis.mapping.BoundSql;
21
import org.apache.ibatis.mapping.MappedStatement;
22
import org.apache.ibatis.mapping.SqlSource;
23
import org.apache.ibatis.parsing.PropertyParser;
24
import org.apache.ibatis.parsing.XNode;
25
import org.apache.ibatis.parsing.XPathParser;
26
import org.apache.ibatis.reflection.ParamNameResolver;
27
import org.apache.ibatis.scripting.LanguageDriver;
28
import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
29
import org.apache.ibatis.scripting.defaults.RawSqlSource;
30
import org.apache.ibatis.session.Configuration;
31

32
/**
33
 * @author Eduardo Macarron
34
 */
35
public class XMLLanguageDriver implements LanguageDriver {
1✔
36

37
  @Override
38
  public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
39
      BoundSql boundSql) {
40
    return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
1✔
41
  }
42

43
  @Override
44
  public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType) {
45
    return createSqlSource(configuration, script, parameterType, null);
1✔
46
  }
47

48
  @Override
49
  public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType,
50
      ParamNameResolver paramNameResolver) {
51
    XMLScriptBuilder builder = new XMLScriptBuilder(configuration, script, parameterType, paramNameResolver);
1✔
52
    return builder.parseScriptNode();
1✔
53
  }
54

55
  @Override
56
  public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
NEW
57
    return createSqlSource(configuration, script, parameterType, null);
×
58
  }
59

60
  @Override
61
  public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType,
62
      ParamNameResolver paramNameResolver) {
63
    // issue #3
64
    if (script.startsWith("<script>")) {
1✔
65
      XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
1✔
66
      return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
1✔
67
    }
68
    // issue #127
69
    script = PropertyParser.parse(script, configuration.getVariables());
1✔
70
    TextSqlNode textSqlNode = new TextSqlNode(script);
1✔
71
    if (textSqlNode.isDynamic()) {
1✔
72
      return new DynamicSqlSource(configuration, textSqlNode);
1✔
73
    } else {
74
      return new RawSqlSource(configuration, script, parameterType, paramNameResolver);
1✔
75
    }
76
  }
77

78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc