Class FreeMarkerSqlTpl

java.lang.Object
org.nutz.dao.impl.sql.NutStatement
org.nutz.dao.impl.sql.NutSql
tech.riemann.nif.nutz.dao.sqltpl.NutSqlTpl
tech.riemann.nif.nutz.dao.sqltpl.freemarker.FreeMarkerSqlTpl
All Implemented Interfaces:
Serializable, org.nutz.dao.sql.DaoStatement, org.nutz.dao.sql.Sql

public class FreeMarkerSqlTpl extends NutSqlTpl
基于FreeMarker模板引擎的SQL模板实现类 该类继承自NutSqlTpl,用于处理使用FreeMarker语法编写的SQL模板
Author:
Kerbores(kerbores@gmail.com)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static freemarker.template.Configuration
    自定义Configuration

    Fields inherited from class NutSqlTpl

    renderComplete

    Fields inherited from class org.nutz.dao.impl.sql.NutSql

    callback, customValueAdaptor, items, paramIndex, params, placeholder, rows, sourceSql, varIndex, vars

    Fields inherited from class org.nutz.dao.impl.sql.NutStatement

    expert
  • Constructor Summary

    Constructors
    Constructor
    Description
    构造函数,创建一个FreeMarkerSqlTpl实例
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.nutz.dao.sql.Sql
    c(org.nutz.dao.sql.Sql sql)
    渲染一个Sql对象,使用FreeMarker模板引擎处理SQL模板 将SQL模板中的变量替换为实际值
    static freemarker.template.Configuration
    cfg()
    获取Configuration配置对象 如果没有自定义的Configuration,则创建一个默认配置
    protected void
    执行SQL模板渲染操作 调用c方法完成实际的模板渲染工作
    static void
    setConfiguration(freemarker.template.Configuration cfg)
    设置自定义Configuration配置对象

    Methods inherited from class org.nutz.dao.impl.sql.NutSql

    _params_count, addBatch, appendSourceSql, changePlaceholder, clearBatch, duplicate, getOutParams, getSourceSql, literal, onAfter, onBefore, paramIndex, params, setCallback, setCondition, setEntity, setPager, setParam, setParams, setSourceSql, setValueAdaptor, setVar, setVars, varIndex, vars

    Methods inherited from class org.nutz.dao.impl.sql.NutStatement

    forceExecQuery, forPrint, getAdapterBy, getBoolean, getContext, getDouble, getDouble, getEntity, getFloat, getFloat, getInt, getInt, getList, getLong, getLong, getNumber, getObject, getResult, getSqlType, getString, getUpdateCount, isAlter, isCall, isCreate, isDelete, isDrop, isExec, isForceExecQuery, isInsert, isOther, isRun, isSelect, isUpdate, param2String, setContext, setExpert, setQueryTimeout, setSqlType, toExampleStatement, toStatement, toString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.nutz.dao.sql.DaoStatement

    forceExecQuery, forPrint, getBoolean, getContext, getDouble, getDouble, getEntity, getFloat, getFloat, getInt, getInt, getList, getLong, getLong, getNumber, getObject, getResult, getSqlType, getString, getUpdateCount, isAlter, isCall, isCreate, isDelete, isDrop, isExec, isForceExecQuery, isInsert, isOther, isRun, isSelect, isUpdate, setExpert, setQueryTimeout, toString
  • Field Details

    • cfg

      protected static volatile freemarker.template.Configuration cfg
      自定义Configuration

      低级: volatile——防止多线程下未初始化读

  • Constructor Details

    • FreeMarkerSqlTpl

      public FreeMarkerSqlTpl(String source)
      构造函数,创建一个FreeMarkerSqlTpl实例
      Parameters:
      source - SQL模板源码
  • Method Details

    • c

      public static org.nutz.dao.sql.Sql c(org.nutz.dao.sql.Sql sql)
      渲染一个Sql对象,使用FreeMarker模板引擎处理SQL模板 将SQL模板中的变量替换为实际值
      Parameters:
      sql - 需要渲染的Sql实例
      Returns:
      原对象,用于链式调用
    • cfg

      public static freemarker.template.Configuration cfg()
      获取Configuration配置对象 如果没有自定义的Configuration,则创建一个默认配置
      Returns:
      Configuration实例
    • setConfiguration

      public static void setConfiguration(freemarker.template.Configuration cfg)
      设置自定义Configuration配置对象
      Parameters:
      cfg - 自定义Configuration实例
    • render

      protected void render()
      执行SQL模板渲染操作 调用c方法完成实际的模板渲染工作
      Specified by:
      render in class NutSqlTpl