com.github.drinkjava2.jdbpro.template
Interface SqlTemplateEngine

All Known Implementing Classes:
BasicSqlTemplate

public interface SqlTemplateEngine

A SqlTemplateEngine render a SQL Template String and a Map into a PreparedSQL instance

Since:
1.7.0
Author:
Yong Zhu

Method Summary
 PreparedSQL render(String sqlTemplateOrSqlID, Map<String,Object> paramMap, Object[] unbindedParams)
          Render a SQL Template String and a Map instance into a PreparedSQL instance
 

Method Detail

render

PreparedSQL render(String sqlTemplateOrSqlID,
                   Map<String,Object> paramMap,
                   Object[] unbindedParams)
Render a SQL Template String and a Map instance into a PreparedSQL instance

Parameters:
sqlTemplateOrSqlID - A SQL Template String, or a SqlId used to locate the real SQL template String
paramMap - A Map instance, key is String type, value is Object type
unbindedParams - Optional, some time un-binded parameter can make template SQL executed like normal SQL, i.e., use normal params to replace placeholder according apperance order
            For example: 
            Template "delete from #{tb}", use put("tb","users") method,      will get "delete from ?"
            Template "delete from ${tb}", use replace("tb","users") method,   will get "delete from users"
            Template "delete from #{tb}", use replace("tb","users") method,   will cause an Exception
            Template "delete from ${tb}", use put("tb","users") method,      will cause an Exception
 
            
This design is to avoid typing mistake cause a SQL injection security leak, when programmer use replace() or replace0() method, he will aware this is a String direct replace method, not a SQL parameter, SQL parameter always use "put" method.
Returns:
PreparedSQL instance


Copyright © 2018. All rights reserved.