I have been googling this for a while and cannot seem to find any real answers.
I have an Oracle stored procedure that has a number of in parameters that have a type that is table of the table rowtype. So for example:
Declared in the pacakge:
TYPE param1_type_t IS TABLE OF table1%ROWTYPE;
TYPE param2_type_t IS TABLE OF table2%ROWTYPE;
TYPE param3_type_t IS TABLE OF table3%ROWTYPE;
Oracle Procedure:
PROCEDURE my_proc
(
parameter1 IN param1_type_t,
parameter2 IN param2_type_t,
parameter3 IN param3_type_t
)
On the java side, I have 3 corresponding Lists of objects representing each of the parameters that are populated in Java. Is it possible to call the Oracle procedure using MyBatis in this scenario?
<update id="callOracleSP" statementType="CALLABLE">
{CALL my_proc( #{param1, mode=IN},
#{param2, mode=IN},
#{param3, mode=IN}
)
}
</update>
The objects themselves are simple VOs with String and Integer properties and their respective getters and setters.
I am not really sure how to proceed. Do I need to somehow map the Java object lists to the Oracle types?
I can't tell if you do already or not, but you'll need Oracle objects defined.
Then you can write type handlers to map the Java objects to the Oracle objects.
Then invoke the procedure,
Andy Pryor's answer is very good I tested it and it really works. But it has an error at typeHandler:
should be:
The TypeHandler has an error as well: (there is no "packs" and there is some difference in the method parameters in my version)
And here is an example for xml mapping:
And here is how you can call it from the DAO:
And my procedure looks like this (it just inserts a row into a test table):