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

mybatis / thymeleaf-scripting / 915

15 Mar 2026 05:24PM UTC coverage: 96.169% (-1.1%) from 97.255%
915

Pull #302

github

web-flow
Merge 1f2c18208 into c20b3f258
Pull Request #302: Compatibility with core 3.6.0

135 of 146 branches covered (92.47%)

Branch coverage included in aggregate %.

30 of 33 new or added lines in 2 files covered. (90.91%)

6 existing lines in 1 file now uncovered.

618 of 637 relevant lines covered (97.02%)

0.97 hits per line

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

88.24
/src/main/java/org/mybatis/scripting/thymeleaf/ThymeleafLanguageDriver.java
1
/*
2
 *    Copyright 2018-2026 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.mybatis.scripting.thymeleaf;
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.reflection.ParamNameResolver;
24
import org.apache.ibatis.scripting.LanguageDriver;
25
import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
26
import org.apache.ibatis.session.Configuration;
27
import org.mybatis.scripting.thymeleaf.support.TemplateFilePathProvider;
28
import org.thymeleaf.ITemplateEngine;
29

30
/**
31
 * The {@code LanguageDriver} for integrating with Thymeleaf.
32
 *
33
 * @author Kazuki Shimizu
34
 *
35
 * @version 1.0.0
36
 */
37
public class ThymeleafLanguageDriver implements LanguageDriver {
38

39
  private final SqlGenerator sqlGenerator;
40

41
  /**
42
   * Constructor for creating instance with default {@code TemplateEngine}.
43
   */
44
  public ThymeleafLanguageDriver() {
1✔
45
    this.sqlGenerator = configure(new SqlGenerator(ThymeleafLanguageDriverConfig.newInstance()));
1✔
46
  }
1✔
47

48
  /**
49
   * Constructor for creating instance with user specified {@code Properties}.
50
   *
51
   * @param config
52
   *          A user defined {@code ITemplateEngine} instance
53
   */
54
  public ThymeleafLanguageDriver(ThymeleafLanguageDriverConfig config) {
1✔
55
    this.sqlGenerator = configure(new SqlGenerator(config));
1✔
56
    TemplateFilePathProvider.setLanguageDriverConfig(config);
1✔
57
  }
1✔
58

59
  /**
60
   * Constructor for creating instance with user defined {@code ITemplateEngine}.
61
   *
62
   * @param templateEngine
63
   *          A user defined {@code ITemplateEngine} instance
64
   */
65
  public ThymeleafLanguageDriver(ITemplateEngine templateEngine) {
1✔
66
    this.sqlGenerator = configure(new SqlGenerator(templateEngine));
1✔
67
  }
1✔
68

69
  private SqlGenerator configure(SqlGenerator sqlGenerator) {
70
    sqlGenerator.setContextFactory(new ThymeleafSqlSource.ContextFactory());
1✔
71
    return sqlGenerator;
1✔
72
  }
73

74
  /**
75
   * {@inheritDoc}
76
   */
77
  @Override
78
  public ParameterHandler createParameterHandler(MappedStatement mappedStatement, Object parameterObject,
79
      BoundSql boundSql) {
80
    return new DefaultParameterHandler(mappedStatement, parameterObject, boundSql);
1✔
81
  }
82

83
  /**
84
   * {@inheritDoc}
85
   */
86
  @Override
87
  public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType) {
NEW
88
    return createSqlSource(configuration, script.getNode().getTextContent(), parameterType, null);
×
89
  }
90

91
  /**
92
   * {@inheritDoc}
93
   */
94
  @Override
95
  public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
NEW
96
    return createSqlSource(configuration, script, parameterType, null);
×
97
  }
98

99
  @Override
100
  public SqlSource createSqlSource(Configuration configuration, XNode script, Class<?> parameterType,
101
      ParamNameResolver paramNameResolver) {
102
    return createSqlSource(configuration, script.getNode().getTextContent(), parameterType, paramNameResolver);
1✔
103
  }
104

105
  @Override
106
  public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType,
107
      ParamNameResolver paramNameResolver) {
108
    return new ThymeleafSqlSource(configuration, sqlGenerator, script.trim(), parameterType, paramNameResolver);
1✔
109
  }
110

111
}
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

© 2026 Coveralls, Inc