We have an Oracle stored procedure that returns its results in a SYS_REFCURSOR type OUT parameter. We would like to call this through a MyBatis mapper, the relevant part of the query string in the @Select annotation looks as follows
@Select(value="call " + SCHEMA_NAME + "." + STORED_PROCEDURE_NAME +
"(" + ...
"#{" + P_RECORDSET_FIELD + ",javaType=java.sql.ResultSet,jdbcType=CURSOR,mode=OUT,resultMap=ownNameSpace.ownResultMap}," +
...
where the resultMap property refers to the following XML configuration
<mapper namespace="ownNameSpace">
<resultMap id="ownResultMap" type="com.ownpackage.OwnResultType">
<result column="COLUMN_1" property="property1" />
...
This works perfectly, the expected results are succesfully retrieved from the DB by the DAO class using the mapper. However we wonder whether it is possible to solve this without XML, using annotations only. MyBatis has @Results/@Result/@ResultMap annotation which we succesfully use for SPs with ResultSet but so far we could not really find a solution for OUT parameters. Similar examples usually boil down to using a mixed annotations+XML configuration. E.g. the author of the following tutorial seems to stuck with the same issue, though it is a few years old: https://dzone.com/articles/ibatis-mybatis-working-stored (see Annotation for Fourth Example) Is this feasible at all?
Try like this..
if you have to pass the IN parameter, use
and then pass the params to
/* All you need to do is declare you result type see below example*/