簡體   English   中英

返回值Mybatis

[英]return value Mybatis

我正在嘗試從Oracle 11g中的存儲函數獲取返回值(Integer值)。

該函數將10添加到輸入數字:

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

在我的mapper界面中,我有一行:

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>

解決方案:MyBatis返回類型必須為void 我正在尋找的結果參數是在函數/過程返回的ResultMap中。

問候。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM