oracle 返回值 Mybatis
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13988935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
return value Mybatis
提问by Charles
I'm trying to get a returned value (an Integer value) from a stored function in Oracle 11g.
我正在尝试从 Oracle 11g 中的存储函数获取返回值(整数值)。
The function adds 10 to the input number:
该函数将输入数字加 10:
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
并在 Xml 文件中
<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.
谢谢你。
采纳答案by Charles
Solution: MyBatis return type must be void
. The result parameter I was looking for is in the ResultMap that function/procedure returns.
解决方案:MyBatis 返回类型必须是void
. 我正在寻找的结果参数在函数/过程返回的 ResultMap 中。
Regards.
问候。
回答by Igor Konoplyanko
Why you haven't defined both parameterType and resultType like this:
为什么你没有像这样定义 parameterType 和 resultType:
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>