public class ExpressionEvaluatingSqlParameterSourceFactory extends AbstractExpressionEvaluator implements SqlParameterSourceFactory
SqlParameterSourceFactory
which creates an SqlParameterSource
that evaluates
Spring EL expressions. In addition the user can supply static parameters that always take precedence.Constructor and Description |
---|
ExpressionEvaluatingSqlParameterSourceFactory() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
org.springframework.jdbc.core.namedparam.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.
|
evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getEvaluationContext, getEvaluationContext, setBeanFactory, setConversionService
public ExpressionEvaluatingSqlParameterSourceFactory()
public void setStaticParameters(java.util.Map<java.lang.String,?> staticParameters)
parameterExpressions
, so a parameter in the query will be filled from here
first, and then from the expressions.staticParameters
- the static parameters to setpublic void setParameterExpressions(java.util.Map<java.lang.String,java.lang.String> parameterExpressions)
static parameters
can be referred to in an expression using the variable #staticParameters
, for example:
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 |
parameterExpressions
- the parameter expressions to setpublic org.springframework.jdbc.core.namedparam.SqlParameterSource createParameterSource(java.lang.Object input)
SqlParameterSourceFactory
SqlParameterSource
.createParameterSource
in interface SqlParameterSourceFactory
input
- the raw message or query result to be transformed into a SqlParameterSourcepublic void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class AbstractExpressionEvaluator
java.lang.Exception