INT-4291 Add ExprEvalSqlPSF.setSqlParameterTypes

JIRA: https://jira.spring.io/browse/INT-4291

* Fix checkstyle trailing space
*Use correct way to constants in spring xml and fix test case

* Polishing - Update javadoc and rename method name to relate more to the behavior
This commit is contained in:
Meherzad Lahewala
2017-11-04 19:32:44 +05:30
committed by Artem Bilan
parent d76af8c2aa
commit 854dba1366
5 changed files with 107 additions and 10 deletions

View File

@@ -81,6 +81,33 @@ The `value` in each parameter expression can be any valid SpEL expression.
The `#root` object for the expression evaluation is the constructor argument defined on the `parameterSource` bean.
It is static for all evaluations (in this case, an empty String).
Starting with _version 5.0_, you can use pass parameter types using `setSqlParameterTypes` method in
the `ExpressionEvaluatingSqlParameterSourceFactory` can be supplied with the sqlParameterTypes to specify the target SQL type for the particular parameter.
Below example provides sql type for the parameters being used in the query.
[source,xml]
----
<int-jdbc:inbound-channel-adapter query="select * from item where status=:status"
channel="target" data-source="dataSource"
select-sql-parameter-source="parameterSource" />
<bean id="parameterSource" factory-bean="parameterSourceFactory"
factory-method="createParameterSourceNoCache">
<constructor-arg value="" />
</bean>
<bean id="parameterSourceFactory"
class="o.s.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
<property name="sqlParameterTypes">
<map>
<entry key="status" value=""#{ T(java.sql.Types).BINARY}" />
</map>
</property>
</bean>
----
IMPORTANT: Use the `createParameterSourceNoCache` factory method; otherwise the parameter source will cache the result of the evaluation.
Also note that, because caching is disabled, if the same parameter name appears in the select query multiple times, it will be re-evaluated for each occurrence.

View File

@@ -292,8 +292,13 @@ The `GemfireMetadataStore` now implements `ListenableMetadataStore`, allowing us
See <<gemfire>> for more information.
==== Jdbc Message Channel Store Changes
==== Jdbc Changes
The `JdbcMessageChannelStore` now provides setter for the `ChannelMessageStorePreparedStatementSetter` allowing users to customize a message insertion in the store.
See <<jdbc-message-store-channels>> for more information.
The `ExpressionEvaluatingSqlParameterSourceFactory` now provides setter for the sqlParameterTypes allowing users
to customize sql types of the parameters.
See <<jdbc-inbound-channel-adapter>> for more information.