Package org.mybatis.scripting.freemarker
Class FreeMarkerLanguageDriver
java.lang.Object
org.mybatis.scripting.freemarker.FreeMarkerLanguageDriver
- All Implemented Interfaces:
org.apache.ibatis.scripting.LanguageDriver
public class FreeMarkerLanguageDriver
extends Object
implements org.apache.ibatis.scripting.LanguageDriver
Adds FreeMarker templates support to scripting in MyBatis. If you want to change or extend template loader
configuration, use can inherit from this class and override
createFreeMarkerConfiguration()
method.- Author:
- elwood, Kazuki Shimizu
-
Field Summary
Modifier and TypeFieldDescriptionprotected final FreeMarkerLanguageDriverConfig
protected final freemarker.template.Configuration
-
Constructor Summary
ConstructorDescriptionConstructor.FreeMarkerLanguageDriver
(FreeMarkerLanguageDriverConfig driverConfig) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected freemarker.template.Configuration
Creates theConfiguration
instance and sets it up.org.apache.ibatis.executor.parameter.ParameterHandler
createParameterHandler
(org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameterObject, org.apache.ibatis.mapping.BoundSql boundSql) Creates aParameterHandler
that passes the actual parameters to the the JDBC statement.protected org.apache.ibatis.mapping.SqlSource
createSqlSource
(freemarker.template.Template template, org.apache.ibatis.session.Configuration configuration) org.apache.ibatis.mapping.SqlSource
createSqlSource
(org.apache.ibatis.session.Configuration configuration, String script, Class<?> parameterType) Creates anSqlSource
that will hold the statement read from an annotation.org.apache.ibatis.mapping.SqlSource
createSqlSource
(org.apache.ibatis.session.Configuration configuration, org.apache.ibatis.parsing.XNode script, Class<?> parameterType) Creates anSqlSource
that will hold the statement read from a mapper xml file.
-
Field Details
-
driverConfig
-
freemarkerCfg
protected final freemarker.template.Configuration freemarkerCfg
-
-
Constructor Details
-
FreeMarkerLanguageDriver
public FreeMarkerLanguageDriver()Constructor.- See Also:
-
FreeMarkerLanguageDriver
Constructor.- Parameters:
driverConfig
- a language driver configuration- Since:
- 1.2.0
-
-
Method Details
-
createFreeMarkerConfiguration
protected freemarker.template.Configuration createFreeMarkerConfiguration()Creates theConfiguration
instance and sets it up. If you want to change it (set another props, for example), you can override it in inherited class and use your own class in @Lang directive. -
createParameterHandler
public org.apache.ibatis.executor.parameter.ParameterHandler createParameterHandler(org.apache.ibatis.mapping.MappedStatement mappedStatement, Object parameterObject, org.apache.ibatis.mapping.BoundSql boundSql) Creates aParameterHandler
that passes the actual parameters to the the JDBC statement.- Specified by:
createParameterHandler
in interfaceorg.apache.ibatis.scripting.LanguageDriver
- Parameters:
mappedStatement
- The mapped statement that is being executedparameterObject
- The input parameter object (can be null)boundSql
- The resulting SQL once the dynamic language has been executed.- See Also:
-
createSqlSource
public org.apache.ibatis.mapping.SqlSource createSqlSource(org.apache.ibatis.session.Configuration configuration, org.apache.ibatis.parsing.XNode script, Class<?> parameterType) Creates anSqlSource
that will hold the statement read from a mapper xml file. It is called during startup, when the mapped statement is read from a class or an xml file.- Specified by:
createSqlSource
in interfaceorg.apache.ibatis.scripting.LanguageDriver
- Parameters:
configuration
- The MyBatis configurationscript
- XNode parsed from a XML fileparameterType
- input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be null.
-
createSqlSource
public org.apache.ibatis.mapping.SqlSource createSqlSource(org.apache.ibatis.session.Configuration configuration, String script, Class<?> parameterType) Creates anSqlSource
that will hold the statement read from an annotation. It is called during startup, when the mapped statement is read from a class or an xml file.- Specified by:
createSqlSource
in interfaceorg.apache.ibatis.scripting.LanguageDriver
- Parameters:
configuration
- The MyBatis configurationscript
- The content of the annotationparameterType
- input parameter type got from a mapper method or specified in the parameterType xml attribute. Can be null.
-
createSqlSource
protected org.apache.ibatis.mapping.SqlSource createSqlSource(freemarker.template.Template template, org.apache.ibatis.session.Configuration configuration)
-