Return Value Mybatis

I am trying to get the return value (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 a line:

 Integer add(Integer input); 

And in the 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 method call looks like this:

 Integer sum = mapper.add(45); 

But I get 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 am really lost with this ...

Thanks.

+6
source share
2 answers

The return type of MyBatis must be void . The result parameter I was looking for is in the ResultMap that the function / procedure returns.

Sincerely.

+1
source

Why didn’t you define both parameter types and resultType as follows:

 parameterType="int" resultType="int" 

Delete the specific output and try to do it like this:

 <select id="add" parameterType="int" resultType="int" statementType="CALLABLE"> { CALL ADD_TEN(#{input, mode=IN, jdbcType=INTEGER})} </select> 
+1
source

All Articles