INT-2580 Add Doc regarding Stored Procedure Name Expressions
This commit is contained in:
committed by
Gary Russell
parent
3a26285b00
commit
194a11983c
@@ -5,8 +5,8 @@
|
||||
|
||||
<para>
|
||||
Spring Integration provides Channel Adapters for receiving and sending
|
||||
messages via database queries. Through those adapters Spring Integration
|
||||
supports not only plain JDBC SQL Queries, but also Stored Procedure and
|
||||
messages via database queries. Through those adapters Spring Integration
|
||||
supports not only plain JDBC SQL Queries, but also Stored Procedure and
|
||||
Stored Function calls.
|
||||
</para>
|
||||
<para>
|
||||
@@ -33,7 +33,7 @@
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>
|
||||
Furthermore, the Spring Integration JDBC Module also provides a
|
||||
Furthermore, the Spring Integration JDBC Module also provides a
|
||||
<emphasis><link linkend='jdbc-message-store'>JDBC Message Store</link></emphasis>
|
||||
</para>
|
||||
|
||||
@@ -115,63 +115,63 @@
|
||||
payload and headers are available by default as input parameters to the
|
||||
query, for instance:
|
||||
</para>
|
||||
|
||||
|
||||
<programlisting language="xml"><![CDATA[<int-jdbc:outbound-channel-adapter
|
||||
query="insert into foos (id, status, name) values (:headers[id], 0, :payload[foo])"
|
||||
data-source="dataSource"
|
||||
channel="input"/>]]></programlisting>
|
||||
|
||||
<para>
|
||||
In the example above, messages arriving on the channel labelled
|
||||
<emphasis>input</emphasis> have a payload of a map with key
|
||||
<emphasis>foo</emphasis>, so the <code>[]</code> operator dereferences
|
||||
In the example above, messages arriving on the channel labelled
|
||||
<emphasis>input</emphasis> have a payload of a map with key
|
||||
<emphasis>foo</emphasis>, so the <code>[]</code> operator dereferences
|
||||
that value from the map. The headers are also accessed as a map.
|
||||
</para>
|
||||
|
||||
|
||||
<note>
|
||||
The parameters in the query above are bean property expressions on the
|
||||
The parameters in the query above are bean property expressions on the
|
||||
incoming message (not Spring EL expressions). This behavior is part of the
|
||||
<classname>SqlParameterSource</classname>
|
||||
which is the default source created by the outbound adapter. Other
|
||||
behavior is possible in the adapter, and requires the user to inject a
|
||||
which is the default source created by the outbound adapter. Other
|
||||
behavior is possible in the adapter, and requires the user to inject a
|
||||
different <classname>SqlParameterSourceFactory</classname>.
|
||||
</note>
|
||||
|
||||
<para>
|
||||
The outbound adapter requires a reference to either a
|
||||
<interfacename>DataSource</interfacename> or a
|
||||
<classname>JdbcTemplate</classname>. It can also have a
|
||||
<classname>SqlParameterSourceFactory</classname> injected to control
|
||||
The outbound adapter requires a reference to either a
|
||||
<interfacename>DataSource</interfacename> or a
|
||||
<classname>JdbcTemplate</classname>. It can also have a
|
||||
<classname>SqlParameterSourceFactory</classname> injected to control
|
||||
the binding of each incoming message to a query.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If the input channel is a direct channel, then the outbound adapter runs
|
||||
If the input channel is a direct channel, then the outbound adapter runs
|
||||
its query in the same thread, and therefore the same transaction (if
|
||||
there is one) as the sender of the message.
|
||||
</para>
|
||||
|
||||
|
||||
<para><emphasis>Passing Parameters using SpEL Expressions</emphasis></para>
|
||||
|
||||
<para>
|
||||
A common requirement for most JDBC Channel Adapters is to pass parameters
|
||||
as part of Sql queries or Stored Procedures/Functions. As mentioned above,
|
||||
these parameters are by default bean property expressions, not SpEL expressions.
|
||||
|
||||
However, if you need to pass SpEL expression as parameters, you must inject
|
||||
these parameters are by default bean property expressions, not SpEL expressions.
|
||||
|
||||
However, if you need to pass SpEL expression as parameters, you must inject
|
||||
a <interfacename>SqlParameterSourceFactory</interfacename> explicitly.
|
||||
</para>
|
||||
<para>
|
||||
The following example uses a <classname>ExpressionEvaluatingSqlParameterSourceFactory</classname>
|
||||
to achieve that requirement.
|
||||
The following example uses a <classname>ExpressionEvaluatingSqlParameterSourceFactory</classname>
|
||||
to achieve that requirement.
|
||||
</para>
|
||||
|
||||
|
||||
<programlisting language="xml"><![CDATA[<jdbc:outbound-channel-adapter data-source="dataSource" channel="input"
|
||||
query="insert into MESSAGES (MESSAGE_ID,PAYLOAD,CREATED_DATE) \
|
||||
values (:id, :payload, :createdDate)"
|
||||
sql-parameter-source-factory="spelSource"/>
|
||||
|
||||
<bean id="spelSource"
|
||||
|
||||
<bean id="spelSource"
|
||||
class="o.s.integration.jdbc.ExpressionEvaluatingSqlParameterSourceFactory">
|
||||
<property name="parameterExpressions">
|
||||
<map>
|
||||
@@ -182,7 +182,7 @@
|
||||
</property>
|
||||
</bean>]]></programlisting>
|
||||
<para>
|
||||
For further information, please also see
|
||||
For further information, please also see
|
||||
<xref linkend="sp-defining-parameter-sources"/>
|
||||
</para>
|
||||
</section>
|
||||
@@ -300,7 +300,7 @@
|
||||
logical name.</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
<section id="stored-procedures">
|
||||
<title>Stored Procedures</title>
|
||||
<para>
|
||||
@@ -309,7 +309,7 @@
|
||||
complex data processing needs, but ultimately you have to use
|
||||
<ulink url="http://en.wikipedia.org/wiki/Stored_procedure">Stored Procedures</ulink>
|
||||
or Stored Functions. Since Spring Integration 2.1, we provide
|
||||
three components in order to execute Stored Procedures or
|
||||
three components in order to execute Stored Procedures or
|
||||
Stored Functions:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
@@ -317,7 +317,7 @@
|
||||
<listitem>Stored Procedures Outbound Channel Adapter</listitem>
|
||||
<listitem>Stored Procedures Outbound Gateway</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
||||
<section id="sp-supported-databases">
|
||||
<title>Supported Databases</title>
|
||||
<para>
|
||||
@@ -355,7 +355,7 @@
|
||||
Stored Procedures or Functions.</para>
|
||||
<para>
|
||||
As a matter of fact, some of the provided integration tests use
|
||||
the <ulink url="http://www.h2database.com/">H2 database</ulink>.
|
||||
the <ulink url="http://www.h2database.com/">H2 database</ulink>.
|
||||
Nevertheless, it is very important to thoroughly test those usage scenarios.
|
||||
</para>
|
||||
</note>
|
||||
@@ -367,7 +367,7 @@
|
||||
JDBC components discussed earlier.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
||||
<section id="sp-common-config-params">
|
||||
<title>Common Configuration Attributes</title>
|
||||
<para>
|
||||
@@ -385,7 +385,7 @@
|
||||
|
||||
<para><emphasis role="bold">data-source</emphasis></para>
|
||||
<para>
|
||||
Reference to a <interfacename>javax.sql.DataSource</interfacename>,
|
||||
Reference to a <interfacename>javax.sql.DataSource</interfacename>,
|
||||
which is used to access the database.
|
||||
<emphasis>Required</emphasis>.
|
||||
</para>
|
||||
@@ -418,19 +418,59 @@
|
||||
</para>
|
||||
|
||||
<para><emphasis role="bold">is-function</emphasis></para>
|
||||
<para>
|
||||
If <code>true</code>, a SQL Function is called. In that case the
|
||||
<code>stored-procedure-name</code> attribute defines the name of
|
||||
the called function. Defaults to <code>false</code>.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
<para>
|
||||
If <code>true</code>, a SQL Function is called. In that case the
|
||||
<code>stored-procedure-name</code> or
|
||||
<code>stored-procedure-name-expression</code> attributes define
|
||||
the name of the called function. Defaults to <code>false</code>.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
<para><emphasis role="bold">stored-procedure-name</emphasis></para>
|
||||
<para>
|
||||
The attribute specifies the name of the stored procedure. If the
|
||||
<code>is-function</code> attribute is set to <code>true</code>,
|
||||
this attribute specifies the function name.
|
||||
<emphasis>Required</emphasis>.
|
||||
</para>
|
||||
<para>
|
||||
The attribute specifies the name of the stored procedure. If the
|
||||
<code>is-function</code> attribute is set to <code>true</code>,
|
||||
this attribute specifies the function name instead. Either this
|
||||
property or <emphasis>stored-procedure-name-expression</emphasis>
|
||||
must be specified.
|
||||
</para>
|
||||
<para><emphasis role="bold">stored-procedure-name-expression</emphasis></para>
|
||||
<para>
|
||||
This attribute specifies the name of the stored procedure using
|
||||
a SpEL expression. Using SpEL you have access to the full message
|
||||
(if available), including its headers and payload. You can use
|
||||
this attribute to invoke different Stored Procedures at runtime.
|
||||
For example, you can provide Stored Procedure names that you would
|
||||
like to execute as a Message Header. The expression must resolve
|
||||
to a String.
|
||||
</para>
|
||||
<para>
|
||||
If the <code>is-function</code> attribute is set to <code>true</code>,
|
||||
this attribute specifies a Stored Function. Either this property
|
||||
or <emphasis>stored-procedure-name</emphasis> must be specified.
|
||||
</para>
|
||||
<para><emphasis role="bold">jdbc-call-operations-cache-size</emphasis></para>
|
||||
<para>
|
||||
Defines the maximum number of cached
|
||||
<interfacename>SimpleJdbcCallOperations</interfacename> instances.
|
||||
Basically, for each Stored Procedure Name a new
|
||||
<ulink url="http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/jdbc/core/simple/SimpleJdbcCallOperations.html"><interfacename>SimpleJdbcCallOperations</interfacename></ulink>
|
||||
instance is created that in return is being cached.
|
||||
</para>
|
||||
<note>
|
||||
The <emphasis>stored-procedure-name-expression</emphasis> attribute
|
||||
and the <emphasis>jdbc-call-operations-cache-size</emphasis>
|
||||
were added with Spring Integration 2.2.
|
||||
</note>
|
||||
<para>
|
||||
The default cache size is <emphasis>10</emphasis>.
|
||||
A value of <emphasis>0</emphasis> disables caching.
|
||||
Negative values are not permitted.
|
||||
</para>
|
||||
<para>
|
||||
If you enable JMX, statistical information about the <emphasis>
|
||||
jdbc-call-operations-cache</emphasis> is exposed as MBean. Please
|
||||
see <xref linkend="jmx-mbean-exporter"/> for more information.
|
||||
</para>
|
||||
<para><emphasis role="bold">sql-parameter-source-factory</emphasis>
|
||||
(Not available for the Stored Procedure Inbound Channel Adapter.)</para>
|
||||
|
||||
@@ -445,39 +485,39 @@
|
||||
<para>
|
||||
This may be sufficient for basic use cases. For more
|
||||
sophisticated options, consider passing in one or more
|
||||
<classname>ProcedureParameter</classname>. Please also refer to
|
||||
<classname>ProcedureParameter</classname>. Please also refer to
|
||||
<xref linkend="sp-defining-parameter-sources"/>.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
|
||||
<para><emphasis role="bold">use-payload-as-parameter-source</emphasis>
|
||||
|
||||
<para><emphasis role="bold">use-payload-as-parameter-source</emphasis>
|
||||
(Not available for the Stored Procedure Inbound Channel Adapter.)</para>
|
||||
|
||||
|
||||
<para>
|
||||
If set to <code>true</code>, the payload of the Message
|
||||
will be used as a source for providing parameters.
|
||||
If false, however, the entire Message will be available as a
|
||||
If set to <code>true</code>, the payload of the Message
|
||||
will be used as a source for providing parameters.
|
||||
If false, however, the entire Message will be available as a
|
||||
source for parameters.
|
||||
</para>
|
||||
<para>
|
||||
<para>
|
||||
If no Procedure Parameters are passed in, this property
|
||||
will default to <code>true</code>. This means that using a default
|
||||
<classname>BeanPropertySqlParameterSourceFactory</classname>
|
||||
the bean properties of the payload will be used as a
|
||||
source for parameter values for the to-be-executed
|
||||
will default to <code>true</code>. This means that using a default
|
||||
<classname>BeanPropertySqlParameterSourceFactory</classname>
|
||||
the bean properties of the payload will be used as a
|
||||
source for parameter values for the to-be-executed
|
||||
Stored Procedure or Stored Function.
|
||||
</para>
|
||||
<para>
|
||||
However, if Procedure Parameters are passed in, then
|
||||
this property will by default evaluate to <code>false</code>.
|
||||
<classname>ProcedureParameter</classname> allow for
|
||||
SpEL Expressions to be provided and therefore it is
|
||||
<para>
|
||||
However, if Procedure Parameters are passed in, then
|
||||
this property will by default evaluate to <code>false</code>.
|
||||
<classname>ProcedureParameter</classname> allow for
|
||||
SpEL Expressions to be provided and therefore it is
|
||||
highly beneficial to have access to the entire Message. The property
|
||||
is set on the underlying <classname>StoredProcExecutor</classname>.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
|
||||
<section id="sp-common-config-subelements">
|
||||
<title>Common Configuration Sub-Elements</title>
|
||||
<para>
|
||||
@@ -590,7 +630,7 @@
|
||||
Defaults to <code>IN</code>. Valid values are:
|
||||
<code>IN</code>,
|
||||
<code>OUT</code> and
|
||||
<code>INOUT</code>.
|
||||
<code>INOUT</code>.
|
||||
If your procedure is returning ResultSets,
|
||||
please use the <code>returning-resultset</code> element.
|
||||
<emphasis>Optional</emphasis>.
|
||||
@@ -632,55 +672,55 @@
|
||||
input parameters. The Stored Procedure components follow certain rules.
|
||||
</para>
|
||||
<para>
|
||||
By default bean properties of the passed in
|
||||
<interfacename>Message</interfacename> payload will be used as a
|
||||
By default bean properties of the passed in
|
||||
<interfacename>Message</interfacename> payload will be used as a
|
||||
source for the Stored Procedure's input parameters. In that case a
|
||||
<classname>BeanPropertySqlParameterSourceFactory</classname> will
|
||||
be used. This may be sufficient for basic use cases. The following
|
||||
<classname>BeanPropertySqlParameterSourceFactory</classname> will
|
||||
be used. This may be sufficient for basic use cases. The following
|
||||
example illustrates that default behavior.
|
||||
</para>
|
||||
<important>
|
||||
Please be aware that for the "automatic" lookup of bean properties
|
||||
using the <classname>BeanPropertySqlParameterSourceFactory</classname>
|
||||
to work, your bean properties must be defined in lower case.
|
||||
This is due to the fact that in
|
||||
<classname>org.springframework.jdbc.core.metadata.CallMetaDataContext</classname>
|
||||
(method matchInParameterValuesWithCallParameters()), the retrieved
|
||||
using the <classname>BeanPropertySqlParameterSourceFactory</classname>
|
||||
to work, your bean properties must be defined in lower case.
|
||||
This is due to the fact that in
|
||||
<classname>org.springframework.jdbc.core.metadata.CallMetaDataContext</classname>
|
||||
(method matchInParameterValuesWithCallParameters()), the retrieved
|
||||
Stored Procedure parameter declarations are converted to lower case.
|
||||
|
||||
As a result, if you have camel-case bean properties such as "lastName",
|
||||
the lookup will fail. In that case, please provide an explicit
|
||||
|
||||
As a result, if you have camel-case bean properties such as "lastName",
|
||||
the lookup will fail. In that case, please provide an explicit
|
||||
<classname>ProcedureParameter</classname>.
|
||||
</important>
|
||||
</important>
|
||||
<para>
|
||||
Let's assume we have a payload that consists of a simple bean with
|
||||
the following three properties: <emphasis>id</emphasis>,
|
||||
<emphasis>name</emphasis> and <emphasis>description</emphasis>.
|
||||
the following three properties: <emphasis>id</emphasis>,
|
||||
<emphasis>name</emphasis> and <emphasis>description</emphasis>.
|
||||
Furthermore, we have a simplistic Stored Procedure called <emphasis>INSERT_COFFEE</emphasis>
|
||||
that accepts three input parameters:
|
||||
that accepts three input parameters:
|
||||
<emphasis>id</emphasis>,
|
||||
<emphasis>name</emphasis> and
|
||||
<emphasis>description</emphasis>. We also use a fully supported
|
||||
<emphasis>description</emphasis>. We also use a fully supported
|
||||
database. In that case the following configuration for a Stored
|
||||
Procedure Oubound Adapter will be sufficient:
|
||||
Procedure Oubound Adapter will be sufficient:
|
||||
</para>
|
||||
<programlisting><![CDATA[<int-jdbc:stored-proc-outbound-channel-adapter data-source="dataSource"
|
||||
channel="insertCoffeeProcedureRequestChannel"
|
||||
stored-procedure-name="INSERT_COFFEE"/>]]></programlisting>
|
||||
<para>
|
||||
For more sophisticated options consider passing in one or more
|
||||
channel="insertCoffeeProcedureRequestChannel"
|
||||
stored-procedure-name="INSERT_COFFEE"/>]]></programlisting>
|
||||
<para>
|
||||
For more sophisticated options consider passing in one or more
|
||||
<classname>ProcedureParameter</classname>.
|
||||
</para>
|
||||
<para>
|
||||
If you do provide <classname>ProcedureParameter</classname> explicitly,
|
||||
<para>
|
||||
If you do provide <classname>ProcedureParameter</classname> explicitly,
|
||||
then as default an <classname>ExpressionEvaluatingSqlParameterSourceFactory</classname>
|
||||
will be used for parameter processing in order to enable the full
|
||||
power of SpEL expressions.
|
||||
</para>
|
||||
<para>
|
||||
Furthermore, if you need even more control over how parameters are
|
||||
retrieved, consider passing in a custom implementation of a
|
||||
<interfacename>SqlParameterSourceFactory</interfacename> using the
|
||||
retrieved, consider passing in a custom implementation of a
|
||||
<interfacename>SqlParameterSourceFactory</interfacename> using the
|
||||
<code>sql-parameter-source-factory</code> attribute.
|
||||
</para>
|
||||
</section>
|
||||
@@ -724,19 +764,19 @@
|
||||
</callout>
|
||||
<callout arearefs="sp-inbound-xml03-co" id="sp-inbound-xml03">
|
||||
<para>
|
||||
If this attribute is set to <code>true</code>, then
|
||||
all results from a stored procedure call that don't
|
||||
have a corresponding <classname>SqlOutParameter</classname>
|
||||
If this attribute is set to <code>true</code>, then
|
||||
all results from a stored procedure call that don't
|
||||
have a corresponding <classname>SqlOutParameter</classname>
|
||||
declaration will be bypassed.
|
||||
</para>
|
||||
<para>
|
||||
E.g. Stored Procedures may return an update count value,
|
||||
even though your Stored Procedure only declared a single
|
||||
result parameter. The exact behavior depends on the used
|
||||
database. The value is set on the underlying
|
||||
database. The value is set on the underlying
|
||||
<classname>JdbcTemplate</classname>.
|
||||
</para>
|
||||
<para>
|
||||
<para>
|
||||
Few developers will probably ever want to process
|
||||
update counts, thus the value defaults to <code>true</code>.
|
||||
<emphasis>Optional</emphasis>.
|
||||
@@ -748,15 +788,15 @@
|
||||
<title>Stored Procedure Outbound Channel Adapter</title>
|
||||
|
||||
<programlisting language="xml"><![CDATA[<int-jdbc:stored-proc-outbound-channel-adapter channel="" ]]><co id="sp-outbound-xml01-co" linkends="sp-outbound-xml01" /><![CDATA[
|
||||
stored-procedure-name=""
|
||||
data-source=""
|
||||
auto-startup="true"
|
||||
id=""
|
||||
ignore-column-meta-data="false"
|
||||
stored-procedure-name=""
|
||||
data-source=""
|
||||
auto-startup="true"
|
||||
id=""
|
||||
ignore-column-meta-data="false"
|
||||
order="" ]]><co id="sp-outbound-xml02-co" linkends="sp-outbound-xml02" /><![CDATA[
|
||||
return-value-required="false" ]]><co id="sp-outbound-xml03-co" linkends="sp-outbound-xml03" /><![CDATA[
|
||||
sql-parameter-source-factory=""
|
||||
use-payload-as-parameter-source="">
|
||||
use-payload-as-parameter-source="">
|
||||
<int:poller fixed-rate=""/>
|
||||
<int-jdbc:sql-parameter-definition name=""/>
|
||||
<int-jdbc:parameter name=""/>
|
||||
@@ -794,19 +834,19 @@
|
||||
<title>Stored Procedure Outbound Gateway</title>
|
||||
|
||||
<programlisting language="xml"><![CDATA[<int-jdbc:stored-proc-outbound-gateway request-channel="" ]]><co id="sp-gateway-xml01-co" linkends="sp-gateway-xml01" /><![CDATA[
|
||||
stored-procedure-name=""
|
||||
data-source=""
|
||||
auto-startup="true"
|
||||
id=""
|
||||
ignore-column-meta-data="false"
|
||||
is-function="false"
|
||||
order=""
|
||||
stored-procedure-name=""
|
||||
data-source=""
|
||||
auto-startup="true"
|
||||
id=""
|
||||
ignore-column-meta-data="false"
|
||||
is-function="false"
|
||||
order=""
|
||||
reply-channel="" ]]><co id="sp-gateway-xml02-co" linkends="sp-gateway-xml02" /><![CDATA[
|
||||
reply-timeout="" ]]><co id="sp-gateway-xml03-co" linkends="sp-gateway-xml03" /><![CDATA[
|
||||
return-value-required="false" ]]><co id="sp-gateway-xml04-co" linkends="sp-gateway-xml04" /><![CDATA[
|
||||
skip-undeclared-results="" ]]><co id="sp-gateway-xml05-co" linkends="sp-gateway-xml05" /><![CDATA[
|
||||
sql-parameter-source-factory=""
|
||||
use-payload-as-parameter-source="">
|
||||
use-payload-as-parameter-source="">
|
||||
<int-jdbc:sql-parameter-definition name="" direction="IN"
|
||||
type=""
|
||||
scale="10"/>
|
||||
@@ -832,15 +872,15 @@
|
||||
</callout>
|
||||
<callout arearefs="sp-gateway-xml03-co" id="sp-gateway-xml03">
|
||||
<para>
|
||||
Allows you to specify how long this gateway will wait
|
||||
for the reply message to be sent successfully before
|
||||
throwing an exception. Keep in mind that when sending
|
||||
to a <classname>DirectChannel</classname>, the invocation
|
||||
will occur in the sender's thread so the failing of the
|
||||
Allows you to specify how long this gateway will wait
|
||||
for the reply message to be sent successfully before
|
||||
throwing an exception. Keep in mind that when sending
|
||||
to a <classname>DirectChannel</classname>, the invocation
|
||||
will occur in the sender's thread so the failing of the
|
||||
send operation may be caused by other components further
|
||||
downstream.
|
||||
|
||||
By default the Gateway will wait indefinitely. The
|
||||
downstream.
|
||||
|
||||
By default the Gateway will wait indefinitely. The
|
||||
value is specified in milliseconds.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
@@ -854,25 +894,25 @@
|
||||
</callout>
|
||||
<callout arearefs="sp-gateway-xml05-co" id="sp-gateway-xml05">
|
||||
<para>
|
||||
If the <code>skip-undeclared-results</code> attribute
|
||||
is set to <code>true</code>, then all results from
|
||||
a stored procedure call that don't have a
|
||||
corresponding <classname>SqlOutParameter</classname>
|
||||
If the <code>skip-undeclared-results</code> attribute
|
||||
is set to <code>true</code>, then all results from
|
||||
a stored procedure call that don't have a
|
||||
corresponding <classname>SqlOutParameter</classname>
|
||||
declaration will be bypassed.
|
||||
</para>
|
||||
<para>
|
||||
E.g. Stored Procedures may return an update count value,
|
||||
even though your Stored Procedure only declared a single
|
||||
result parameter. The exact behavior depends on the used
|
||||
database. The value is set on the underlying
|
||||
database. The value is set on the underlying
|
||||
<classname>JdbcTemplate</classname>.
|
||||
</para>
|
||||
<para>
|
||||
<para>
|
||||
Few developers will probably ever want to process
|
||||
update counts, thus the value defaults to <code>true</code>.
|
||||
<emphasis>Optional</emphasis>.
|
||||
</para>
|
||||
</callout>
|
||||
</callout>
|
||||
</calloutlist>
|
||||
</para>
|
||||
</section>
|
||||
@@ -886,33 +926,33 @@
|
||||
Spring Integration message payload.
|
||||
</para>
|
||||
<para>
|
||||
In the second sample we call a Stored Procedure that uses
|
||||
In the second sample we call a Stored Procedure that uses
|
||||
Output Parameters instead, in order to return data.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Please have a look at the <emphasis>Spring Integration Samples</emphasis>
|
||||
project, located at
|
||||
project, located at
|
||||
<ulink url="https://github.com/SpringSource/spring-integration-samples"/>
|
||||
</para>
|
||||
<para>
|
||||
The project contains the Apache Derby example referenced
|
||||
here, as well as instruction on how to run it. The
|
||||
<emphasis>Spring Integration Samples</emphasis> project also
|
||||
provides an
|
||||
<ulink url="https://github.com/SpringSource/spring-integration-samples/tree/master/intermediate/stored-procedures-oracle">example</ulink>
|
||||
here, as well as instruction on how to run it. The
|
||||
<emphasis>Spring Integration Samples</emphasis> project also
|
||||
provides an
|
||||
<ulink url="https://github.com/SpringSource/spring-integration-samples/tree/master/intermediate/stored-procedures-oracle">example</ulink>
|
||||
using Oracle Stored Procedures.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
In the first example, we call a Stored Procedure named
|
||||
<emphasis>FIND_ALL_COFFEE_BEVERAGES</emphasis> that does not
|
||||
define any input parameters but which returns a <classname>ResultSet</classname>.
|
||||
In the first example, we call a Stored Procedure named
|
||||
<emphasis>FIND_ALL_COFFEE_BEVERAGES</emphasis> that does not
|
||||
define any input parameters but which returns a <classname>ResultSet</classname>.
|
||||
</para>
|
||||
<para>
|
||||
In Apache Derby, Stored Procedures are implemented using Java. Here
|
||||
In Apache Derby, Stored Procedures are implemented using Java. Here
|
||||
is the method signature followed by the corresponding Sql:
|
||||
</para>
|
||||
</para>
|
||||
<programlisting language="java"><![CDATA[public static void findAllCoffeeBeverages(ResultSet[] coffeeBeverages)
|
||||
throws SQLException {
|
||||
...
|
||||
@@ -924,24 +964,24 @@ EXTERNAL NAME 'org.springframework.integration.jdbc.storedproc.derby.DerbyStored
|
||||
]]></programlisting>
|
||||
|
||||
<para>
|
||||
In Spring Integration, you can now call this Stored Procedure using
|
||||
In Spring Integration, you can now call this Stored Procedure using
|
||||
e.g. a <code>stored-proc-outbound-gateway</code>
|
||||
</para>
|
||||
<programlisting language="xml"><![CDATA[<int-jdbc:stored-proc-outbound-gateway id="outbound-gateway-storedproc-find-all"
|
||||
<programlisting language="xml"><![CDATA[<int-jdbc:stored-proc-outbound-gateway id="outbound-gateway-storedproc-find-all"
|
||||
data-source="dataSource"
|
||||
request-channel="findAllProcedureRequestChannel"
|
||||
request-channel="findAllProcedureRequestChannel"
|
||||
expect-single-result="true"
|
||||
stored-procedure-name="FIND_ALL_COFFEE_BEVERAGES">
|
||||
<int-jdbc:returning-resultset name="coffeeBeverages"
|
||||
<int-jdbc:returning-resultset name="coffeeBeverages"
|
||||
row-mapper="org.springframework.integration.support.CoffeBeverageMapper"/>
|
||||
</int-jdbc:stored-proc-outbound-gateway>]]></programlisting>
|
||||
|
||||
|
||||
<para>
|
||||
In the second example, we call a Stored Procedure named
|
||||
In the second example, we call a Stored Procedure named
|
||||
<emphasis>FIND_COFFEE</emphasis> that has one input parameter. Instead
|
||||
of returning a ResultSet, an output parameter is used:
|
||||
</para>
|
||||
|
||||
|
||||
<programlisting language="java"><![CDATA[public static void findCoffee(int coffeeId, String[] coffeeDescription)
|
||||
throws SQLException {
|
||||
...
|
||||
@@ -952,18 +992,18 @@ PARAMETER STYLE JAVA LANGUAGE JAVA EXTERNAL NAME \
|
||||
'org.springframework.integration.jdbc.storedproc.derby.DerbyStoredProcedures.findCoffee';]]></programlisting>
|
||||
|
||||
<para>
|
||||
In Spring Integration, you can now call this Stored Procedure using
|
||||
In Spring Integration, you can now call this Stored Procedure using
|
||||
e.g. a <code>stored-proc-outbound-gateway</code>
|
||||
</para>
|
||||
<programlisting language="xml"><![CDATA[<int-jdbc:stored-proc-outbound-gateway id="outbound-gateway-storedproc-find-coffee"
|
||||
</para>
|
||||
<programlisting language="xml"><![CDATA[<int-jdbc:stored-proc-outbound-gateway id="outbound-gateway-storedproc-find-coffee"
|
||||
data-source="dataSource"
|
||||
request-channel="findCoffeeProcedureRequestChannel"
|
||||
request-channel="findCoffeeProcedureRequestChannel"
|
||||
skip-undeclared-results="true"
|
||||
stored-procedure-name="FIND_COFFEE"
|
||||
expect-single-result="true">
|
||||
<int-jdbc:parameter name="ID" expression="payload" />
|
||||
</int-jdbc:stored-proc-outbound-gateway>]]></programlisting>
|
||||
|
||||
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
@@ -32,6 +32,31 @@
|
||||
<listitem>Support for Dead Letter Exchanges/Dead Letter Queues</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="2.2-jdbc-11">
|
||||
<title>JDBC Adapter - Stored Procedures Components</title>
|
||||
<para><emphasis>SpEL Support</emphasis></para>
|
||||
<para>
|
||||
When using the Stored Procedure components of the Spring Integration
|
||||
JDBC Adapter, you can now provide Stored Procedure Names or
|
||||
Stored Function Names using Spring Expression Language (SpEL).
|
||||
</para>
|
||||
<para>
|
||||
This allows you to specify the Stored Procedures to be invoked
|
||||
at runtime. For example, you can provide Stored Procedure names
|
||||
that you would like to execute via Message Headers. For more
|
||||
information please see <xref linkend="stored-procedures"/>.
|
||||
</para>
|
||||
<para><emphasis>JMX Support</emphasis></para>
|
||||
<para>
|
||||
The Stored Procedure components now provide basic JMX support,
|
||||
exposing some of their properties as MBeans:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>Stored Procedure Name</listitem>
|
||||
<listitem>Stored Procedure Name Expression</listitem>
|
||||
<listitem>JdbcCallOperations Cache Statistics</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id="2.2-new-components">
|
||||
|
||||
Reference in New Issue
Block a user