return value Mybatis
22,318
Solution 1
Solution: MyBatis return type must be void
. The result parameter I was looking for is in the ResultMap that function/procedure returns.
Regards.
Solution 2
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>
Author by
Charles
Updated on August 05, 2022Comments
-
Charles over 1 year
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.