We use MyBatis for ORM. I need to call an Oracle Function which takes a cursor as a parameter. It would be ideal if MyBatis could map a Java object to the cursor but I doubt that is possible.
Any ideas how to do that?
Please note that I know how map a cursor returned from a function to a Java object. The other way around is the issue.
It seems like the only solution is to create a block, declare a cursor and pass it to the function manually:
<select id="..." parameterType="..." statementType="CALLABLE">
declare
my_cursor SYS_REFCURSOR;
begin
OPEN my_cursor FOR
<foreach item="item" collection="..." separator=" union all ">
SELECT #{item.key} as key, ... FROM dual
</foreach> ;
#{result,jdbcType=CURSOR,mode=OUT,resultMap=...,javaType=java.sql.ResultSet} := our_function(my_cursor => my_cursor);
end;
</select>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.