I'm trying to get a returned value (an Integer value) from a stored function in Oracle 11g.
The function adds 10 to the input number:
FUNCTION ADD_TEN(INPUT IN NUMBER) RETURN NUMBER IS
BEGIN
RETURN INPUT + 10;
END;
In my mapper interface I have the line:
Integer add(Integer input);
And in Xml file
<select id="add" statementType="CALLABLE" resultType='java.lang.Integer'>
{#{output,mode=OUT,jdbcType=NUMERIC,javaType=Integer} = call test_pkg.ADD_TEN(
#{input,jdbcType=NUMERIC}) }
</select>`
The call to the method is like:
Integer sum = mapper.add(45);
But I'm getting the following error:
Could not set property 'output' of 'class java.lang.Integer' with value '55' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'output' in 'class java.lang.Integer'
What am I doing wrong? I'm really lost with this...
Thank you.
MyBatis is a fork from iBATIS, and according to Wikipedia most of iBATIS' developers moved over to MyBatis too. The iBATIS project is currently marked as Inactive, therefore you should go with MyBatis for new projects and only use iBATIS if you're maintaining an existing project which already uses iBATIS.
MyBatis is a SQL mapping framework with support for custom SQL, stored procedures, and advanced mapping. Although SpringBoot does not officially support MyBatis, the MyBatis community has created a SpringBoot startup for MyBatis.
The resultMap element is the most important and powerful element in MyBatis. It's what allows you to do away with 90% of the code that JDBC requires to retrieve data from ResultSet s, and in some cases allows you to do things that JDBC does not even support.
Why you haven't defined both parameterType and resultType like this:
parameterType="int" resultType="int"
Remove specific output and try to make it like this:
<select id="add" parameterType="int" resultType="int" statementType="CALLABLE">
{ CALL ADD_TEN(#{input, mode=IN, jdbcType=INTEGER})}
</select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With