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() |
SqlParameterSource |
createParameterSource(Object input)
Return a new
SqlParameterSource . |
SqlParameterSource |
createParameterSourceNoCache(Object input)
Create an expression evaluating
SqlParameterSource that does not cache it's results. |
void |
setParameterExpressions(Map<String,String> parameterExpressions)
Optionally maps parameter names to explicit expressions.
|
void |
setStaticParameters(Map<String,?> staticParameters)
Define some static parameter values.
|
evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionService
public ExpressionEvaluatingSqlParameterSourceFactory()
public void setStaticParameters(Map<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(Map<String,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 SqlParameterSource createParameterSource(Object input)
SqlParameterSourceFactory
SqlParameterSource
.createParameterSource
in interface SqlParameterSourceFactory
input
- the raw message or query result to be transformed into a SqlParameterSourcepublic SqlParameterSource createParameterSourceNoCache(Object input)
SqlParameterSource
that does not cache it's results. Useful for cases
where the source is used multiple times, for example in a <int-jdbc:inbound-channel-adapter/>
for the
select-sql-parameter-source
attribute.input
- The root object for the evaluation.public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class AbstractExpressionEvaluator
Exception