1
votes

I am newbie to Spring Integration and am using Spring 4.2.4. I am trying to invoke stored procedure with jdbc:stored-proc-outbound-gateway. i am already using spring jdbc.

Stored procedure is returning cursor and am using customRowMapper like below

 new SqlOutParameter(A_RC, OracleTypes.CURSOR, null, new MyCustomDataExtractor())

MyCustomDataExtractor implements SqlReturnType and it returns custom object.

Now the question is how can I achieve this in SI jdbc stored proc.piece of my code here..

    ...
<int-jdbc:sql-parameter-definition name="A_RC" type="#{T(oracle.jdbc.OracleTypes).CURSOR}" direction="OUT"/>
...
 <int-jdbc:returning-resultset name="A_RC" row-mapper="a.b.c.MyCustomDataExtractor"/>
...

Spring expect this as a row mapper. should I use any transformer here? Please advice. Note : I have to return multiple resultset.

2

2 Answers

1
votes

Actually with the CURSOR type you are good to go with just a returning-resultset and RowMapper implementation.

With that you don't need to worry about any SqlReturnType and just map the row to your domain object directly.

I'm even sure you can rework your MyCustomDataExtractor to the RowMapper contract.

Note: with returning-resultset defintion you don't need to specify the sql-parameter-definition for the same OUT param. The component identifies them correctly as a OutParameter.

And, yes you can have several returning-resultset for CURSOR parameters.

0
votes

I added the return-type in the sql-parameter-definition and removed returning-resultset.

<int-jdbc:sql-parameter-definition name="A_RC" type="#{T(oracle.jdbc.OracleTypes).CURSOR}" direction="OUT" return-type="ed"/>

and here "ed" is nothing but the bean reference for a.b.c.MyCustomDataExtractor.

<bean id="ed" class="a.b.c.MyCustomDataExtractor"/>