Tuesday, 20 August 2013

Passing a cursor to an Oracle stored procedure via MyBatis

Passing a cursor to an Oracle stored procedure via MyBatis

I have a stored procedure which takes a list of records as a cursor. I
would like to call it from a MyBatis mapper. I assumed that this would be
similar to reading a cursor as an output parameter, but this does not
appear to be the case. Below is the mapper entry:
@Select({CALL pkg_transaction_info.pr_transaction_add("
+ "#{pcur_trx_info, mode=IN, jdbcType=CURSOR,
javaType=java.sql.ResultSet, resultMap=txnInfoRM})
@ResultMap("txnInfoRM")
@Options(statementType = StatementType.CALLABLE)
public void addTransactionInfo(Map<String, Object> params);
... where txnInfoRM describes the mapping between my Java objects and the
columns that the stored procedure expects. In the parameter map I've tried
passing in a list of objects, hoping that the translation to a ResultSet
would happen implicitly, as it does when receiving a cursor as an output
parameter, but to no avail. Is it even possible to pass in a Cursor in
this manner? Do I need to write a custom typehandler to open it for me
using the Oracle api?

No comments:

Post a Comment