Search code examples
spring-integrationspring-el

How to set non-caching SqlParameterSource on JdbcPollingChannelAdapter update parameters


In the JdbcPollingChannelAdapter, I think I understand how to use the createParameterSourceNoCache() method of the ExpressionEvaluatingSqlParameterSourceFactory class in order to get a non-caching SqlParameterSource object that can be applied to the JdbcPollingChannelAdapter's select parameters via its setSelectSqlParameterSource() method.

However, when it comes to update parameters, I only see it possible to set the update parameters via a SqlParameterSourceFactory through the setUpdateSqlParameterSourceFactory() method. From what I can tell, it is not possible to set the factory to be non-caching, only to call the non-caching create method of the factory to get a non-caching source object.

I need the update parameter to be the result of a dynamically calculated custom date that changes over time. I have a static method to dynamically calculate the result, and I was hoping I could use SpEL on the JdbcPollingChannelAdapter to evaluate the update parameter dynamically in the same way that the select parameter can do. Is this possible?


Solution

  • You can extend it and still inject it regular way into the JdbcPollingChannelAdapter:

    public class NoCacheExpressionEvaluatingSqlParameterSourceFactory 
            extends ExpressionEvaluatingSqlParameterSourceFactory {
    
        @Override
        public SqlParameterSource createParameterSource(Object input) {
            return createParameterSourceNoCache(input);
        }
    
    }