StatementPreparer

This class has several methods that create java.sql.PreparedStatements from a SQL template and a map of parameter values. SQL templates are used as flexible way of creating dynamic SQL without embedding SQL statements into Java code.

The following steps describe the process used by StatementPreparer to create a PreparedStatement:

Locates the SQL template identified by the specified key.
The template is processed by FreeMarker using the parameters as the context.
The result is then converted into the prepared statement format by replacing named parameters (ie :customerId) with '?' characters.
A PreparedStatement is created and the parameter values are bound in the correct order.

Here is an example of this process.

FreeMarker

FreeMarker is an open source template engine. More information about FreeMarker and the template syntax that it uses can be found on its website at http://freemarker.org/docs/index.html.

Related topics

StatementPreparer example