org.springframework.integration.jdbc
Class ExpressionEvaluatingSqlParameterSourceFactory

java.lang.Object
  extended by org.springframework.integration.util.AbstractExpressionEvaluator
      extended by org.springframework.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory
All Implemented Interfaces:
BeanFactoryAware, SqlParameterSourceFactory

public class ExpressionEvaluatingSqlParameterSourceFactory
extends AbstractExpressionEvaluator
implements SqlParameterSourceFactory

An implementation of SqlParameterSourceFactory which creates an SqlParameterSource that evaluates Spring EL expressions. In addition the user can supply static parameters that always take precedence.

Since:
2.0

Constructor Summary
ExpressionEvaluatingSqlParameterSourceFactory()
           
 
Method Summary
 SqlParameterSource createParameterSource(java.lang.Object input)
          Return a new SqlParameterSource.
 void setParameterExpressions(java.util.Map<java.lang.String,java.lang.String> parameterExpressions)
          Optionally maps parameter names to explicit expressions.
 void setStaticParameters(java.util.Map<java.lang.String,?> staticParameters)
          Define some static parameter values.
 
Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getEvaluationContext, setBeanFactory, setBeanResolver, setConversionService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionEvaluatingSqlParameterSourceFactory

public ExpressionEvaluatingSqlParameterSourceFactory()
Method Detail

setStaticParameters

public void setStaticParameters(java.util.Map<java.lang.String,?> staticParameters)
Define some static parameter values. These take precedence over those defined as expressions in the parameterExpressions, so a parameter in the query will be filled from here first, and then from the expressions.

Parameters:
staticParameters - the static parameters to set

setParameterExpressions

public void setParameterExpressions(java.util.Map<java.lang.String,java.lang.String> parameterExpressions)
Optionally maps parameter names to explicit expressions. The named parameter support in Spring is limited to simple parameter names with no special characters, so this feature allows you to specify a simple name in the SQL query and then have it translated into an expression at runtime. The target of the expression depends on the context: generally in an outbound setting it is a Message, and in an inbound setting it is a result set row (a Map or a domain object if a RowMapper has been provided). The static parameters can be referred to in an expression using the variable #staticParameters, for example:

Parameters:
parameterExpressions - the parameter expressions to set

createParameterSource

public SqlParameterSource createParameterSource(java.lang.Object input)
Description copied from interface: SqlParameterSourceFactory
Return a new SqlParameterSource.

Specified by:
createParameterSource in interface SqlParameterSourceFactory
Parameters:
input - the raw message or query result to be transformed into a SqlParameterSource

Key Value (Expression) Example SQL
id payload.businessKey select * from items where id=:id
date headers['timestamp'] select * from items where created>:date
key #staticParameters['foo'].toUpperCase() select * from items where name=:key