Class TemplateFilePathProvider
java.lang.Object
org.mybatis.scripting.thymeleaf.support.TemplateFilePathProvider
The SQL provider class that return the SQL template file path.
IMPORTANT: This class required to use with mybatis 3.5.1+ and need to use with SQL provider annotation (such as
IMPORTANT: This class required to use with mybatis 3.5.1+ and need to use with SQL provider annotation (such as
SelectProvider
as follow: package com.example.mapper; public interface BaseMapper<T> { @Options(useGeneratedKeys = true, keyProperty = "id") @InsertProvider(type = TemplateFilePathProvider.class) void insert(T entity); @UpdateProvider(type = TemplateFilePathProvider.class) void update(T entity); @DeleteProvider(type = TemplateFilePathProvider.class) void delete(T entity); @SelectProvider(type = TemplateFilePathProvider.class) T findById(Integer id); }
package com.example.mapper; public interface NameMapper extends BaseMapper { @SelectProvider(type = TemplateFilePathProvider.class) List<Name> findByConditions(NameConditions conditions); }
- Version:
- 1.0.1
- Author:
- Kazuki Shimizu
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
The interface that implements a function for generating template file path. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clear cache.static String
provideSql
(org.apache.ibatis.builder.annotation.ProviderContext context) Provide an SQL scripting string(template file path).static void
Set custom implementation forTemplateFilePathProvider.PathGenerator
.static void
setLanguageDriverConfig
(ThymeleafLanguageDriverConfig languageDriverConfig) Set a configuration instance forThymeleafLanguageDriver
.
-
Method Details
-
setCustomTemplateFilePathGenerator
public static void setCustomTemplateFilePathGenerator(TemplateFilePathProvider.PathGenerator pathGenerator) Set custom implementation forTemplateFilePathProvider.PathGenerator
.- Parameters:
pathGenerator
- a instance for generating a template file path
-
setLanguageDriverConfig
Set a configuration instance forThymeleafLanguageDriver
.By default,
ThymeleafLanguageDriverConfig.newInstance()
will used.If you applied an user define
ThymeleafLanguageDriverConfig
forThymeleafLanguageDriver
, please same instance to the this class.- Parameters:
languageDriverConfig
- A user definedThymeleafLanguageDriverConfig
-
provideSql
Provide an SQL scripting string(template file path).
By default implementation, a template file path resolve following format and priority order. If does not match all, it throw an exception that indicate not found a template file.- com/example/mapper/NameMapper/NameMapper-{methodName}-{databaseId}.sql
- com/example/mapper/NameMapper/NameMapper-{methodName}.sql (fallback using default database)
- com/example/mapper/BaseMapper/BaseMapper-{methodName}-{databaseId}.sql (fallback using declaring class of method)
- com/example/mapper/BaseMapper/BaseMapper-{methodName}.sql (fallback using declaring class of method and default database)
- Parameters:
context
- a context of SQL provider- Returns:
- an SQL scripting string(template file path)
-
clearCache
public static void clearCache()Clear cache.
-