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

    Fields
    Modifier and Type
    Field
    Description
     
    protected final freemarker.template.Configuration
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected freemarker.template.Configuration
    Creates the Configuration 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 a ParameterHandler 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 an SqlSource 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 an SqlSource that will hold the statement read from a mapper xml file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • driverConfig

      protected final FreeMarkerLanguageDriverConfig driverConfig
    • freemarkerCfg

      protected final freemarker.template.Configuration freemarkerCfg
  • Constructor Details

  • Method Details

    • createFreeMarkerConfiguration

      protected freemarker.template.Configuration createFreeMarkerConfiguration()
      Creates the Configuration 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 a ParameterHandler that passes the actual parameters to the the JDBC statement.
      Specified by:
      createParameterHandler in interface org.apache.ibatis.scripting.LanguageDriver
      Parameters:
      mappedStatement - The mapped statement that is being executed
      parameterObject - The input parameter object (can be null)
      boundSql - The resulting SQL once the dynamic language has been executed.
      See Also:
      • DefaultParameterHandler
    • createSqlSource

      public org.apache.ibatis.mapping.SqlSource createSqlSource(org.apache.ibatis.session.Configuration configuration, org.apache.ibatis.parsing.XNode script, Class<?> parameterType)
      Creates an SqlSource 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 interface org.apache.ibatis.scripting.LanguageDriver
      Parameters:
      configuration - The MyBatis configuration
      script - XNode parsed from a XML file
      parameterType - 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 an SqlSource 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 interface org.apache.ibatis.scripting.LanguageDriver
      Parameters:
      configuration - The MyBatis configuration
      script - The content of the annotation
      parameterType - 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)