gpt4 book ai didi

java - 返回值

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:34:38 24 4
gpt4 key购买 nike

我正在尝试从 Oracle 11g 中的存储函数获取返回值(整数值)。

该函数将输入数字加 10:

FUNCTION ADD_TEN(INPUT IN NUMBER) RETURN NUMBER IS 
BEGIN
RETURN INPUT + 10;
END;

在我的映射器界面中,我有一行:

Integer add(Integer input); 

在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>`

方法调用如下:

Integer sum = mapper.add(45); 

但是我收到以下错误:

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' 

我做错了什么?我真的迷失了……

谢谢。

最佳答案

为什么你没有像这样定义 parameterType 和 resultType:

parameterType="int" resultType="int"

删除特定的输出并尝试像这样:

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

关于java - 返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13988935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com