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.EXPRESSION_PARSER, logger
Constructor and Description |
---|
ExpressionEvaluatingSqlParameterSourceFactory() |
Modifier and Type | Method and Description |
---|---|
SqlParameterSource |
createParameterSource(Object input)
Return a new
SqlParameterSource . |
SqlParameterSource |
createParameterSourceNoCache(Object input)
Create an expression evaluating
SqlParameterSource that does not cache it's results. |
protected void |
onInit() |
void |
setParameterExpressions(Map<String,String> parameterExpressions)
Optionally maps parameter names to explicit expressions.
|
void |
setSqlParameterTypes(Map<String,Integer> sqlParametersTypes)
Specify sql types for the parameters.
|
void |
setStaticParameters(Map<String,Object> staticParameters)
Define some static parameter values.
|
afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionService
public ExpressionEvaluatingSqlParameterSourceFactory()
public void setStaticParameters(Map<String,Object> 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 void setSqlParameterTypes(Map<String,Integer> sqlParametersTypes)
Types
to get the parameter type value.sqlParametersTypes
- the parameter types to useTypes
public 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.protected void onInit()
onInit
in class AbstractExpressionEvaluator