【问题标题】:return value Mybatis返回值 Mybatis
【发布时间】:2012-12-08 23:06:16
【问题描述】:

我正在尝试从 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' 

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

谢谢。

【问题讨论】:

    标签: java oracle return mybatis


    【解决方案1】:

    解决方法:MyBatis 返回类型必须为void。我正在寻找的结果参数在函数/过程返回的 ResultMap 中。

    问候。

    【讨论】:

      【解决方案2】:

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

      parameterType="int" resultType="int"
      

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

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

      【讨论】:

      • 如果在增加 count 值后返回值,我们可以在更新中执行此操作吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 2014-01-30
      相关资源
      最近更新 更多