org.springframework.integration.jdbc
Class StoredProcOutboundGateway
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractReplyProducingMessageHandler
org.springframework.integration.jdbc.StoredProcOutboundGateway
- All Implemented Interfaces:
- BeanFactoryAware, BeanNameAware, InitializingBean, Ordered, NamedComponent, Orderable, MessageHandler, MessageProducer, TrackableComponent
public class StoredProcOutboundGateway
- extends AbstractReplyProducingMessageHandler
- Since:
- 2.1
Constructor Summary |
StoredProcOutboundGateway(javax.sql.DataSource dataSource,
java.lang.String storedProcedureName)
Constructor taking DataSource from which the DB Connection can be
obtained and the name of the stored procedure or function to
execute to retrieve new rows. |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
StoredProcOutboundGateway
public StoredProcOutboundGateway(javax.sql.DataSource dataSource,
java.lang.String storedProcedureName)
- Constructor taking
DataSource
from which the DB Connection can be
obtained and the name of the stored procedure or function to
execute to retrieve new rows.
- Parameters:
dataSource
- used to create a SimpleJdbcTemplate
storedProcedureName
-
onInit
protected void onInit()
- Verifies parameters, sets the parameters on
SimpleJdbcCallOperations
and ensures the appropriate SqlParameterSourceFactory
is defined
when ProcedureParameter
are passed in.
- Overrides:
onInit
in class AbstractReplyProducingMessageHandler
handleRequestMessage
protected java.lang.Object handleRequestMessage(Message<?> requestMessage)
- Description copied from class:
AbstractReplyProducingMessageHandler
- Subclasses must implement this method to handle the request Message. The return
value may be a Message, a MessageBuilder, or any plain Object. The base class
will handle the final creation of a reply Message from any of those starting
points. If the return value is null, the Message flow will end here.
- Specified by:
handleRequestMessage
in class AbstractReplyProducingMessageHandler
setSqlParameters
public void setSqlParameters(java.util.List<SqlParameter> sqlParameters)
- Explicit declarations are necessary if the database you use is not a
Spring-supported database. Currently Spring supports metadata lookup of
stored procedure calls for the following databases:
- Apache Derby
- DB2
- MySQL
- Microsoft SQL Server
- Oracle
- Sybase
- PostgreSQL
, ,
We also support metadata lookup of stored functions for the following
databases:
- MySQL
- Microsoft SQL Server
- Oracle
- PostgreSQL
See also: http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/jdbc.html
setReturningResultSetRowMappers
public void setReturningResultSetRowMappers(java.util.Map<java.lang.String,RowMapper<?>> returningResultSetRowMappers)
- Does your stored procedure return one or more result sets? If so, you
can use the provided method for setting the respective Rowmappers.
setIgnoreColumnMetaData
public void setIgnoreColumnMetaData(boolean ignoreColumnMetaData)
- Parameters:
ignoreColumnMetaData
-
setReturnValueRequired
public void setReturnValueRequired(boolean returnValueRequired)
- Parameters:
returnValueRequired
-
setProcedureParameters
public void setProcedureParameters(java.util.List<ProcedureParameter> procedureParameters)
setIsFunction
public void setIsFunction(boolean isFunction)
setExpectSingleResult
public void setExpectSingleResult(boolean expectSingleResult)
- This parameter indicates that only one result object shall be returned from
the Stored Procedure/Function Call. If set to true, a resultMap that contains
only 1 element, will have that 1 element extracted and returned as payload.
If the resultMap contains more than 1 element and expectSingleResult is true,
then a
MessagingException
is thrown.
Otherwise the complete resultMap is returned as the Message
payload.
Important Note: Several databases such as H2 are not fully supported.
The H2 database, for example, does not fully support the CallableStatement
semantics and when executing function calls against H2, a result list is
returned rather than a single value.
Therefore, even if you set expectSingleResult = true, you may end up with
a collection being returned.
- Parameters:
expectSingleResult
-
setSqlParameterSourceFactory
public void setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
- Parameters:
sqlParameterSourceFactory
-
setUsePayloadAsParameterSource
public void setUsePayloadAsParameterSource(boolean usePayloadAsParameterSource)
- If set to 'true', the payload of the Message will be used as a source for
providing parameters. If false the entire Message will be available as a
source for parameters.
If no
ProcedureParameter
are passed in, this property will default to
'true'. This means that using a default BeanPropertySqlParameterSourceFactory
the bean properties of the payload will be used as a source for parameter values for
the to-be-executed Stored Procedure or Function.
However, if ProcedureParameter
are passed in, then this property
will by default evaluate to 'false'. ProcedureParameter
allow for
SpEl Expressions to be provided and therefore it is highly beneficial to
have access to the entire Message
.
- Parameters:
usePayloadAsParameterSource
- If false the entire Message
is used as parameter source.