`

ibatis 调用存储过程返回游标问题

阅读更多
存储过程:
create or replace procedure P_search(weight_value in integer, p_cursor out types.searchNature_CURSOR) as
begin
  open p_cursor for
    select globalId
      from (select sum(WEIGHT) as w, globalId
              from EMPI_TEMP
             group by globalId
             order by sum(WEIGHT) desc)
     where w > weight_value;

end P_search;


sqlMap.xml:

<parameterMap id="test_map" class="java.util.HashMap">
<parameter property="weight_value" jdbcType="INTEGER"
javaType="java.lang.Integer" mode="IN" />
<parameter property="p_cursor" jdbcType="ORACLECURSOR"
javaType="java.sql.ResultSet" mode="OUT"/>
</parameterMap>
<procedure id="query_search" parameterMap="test_map" resultClass="java.lang.String">
{call p_search(?,?)}
   </procedure>

java:

SqlMapClient client =  IBatisConfig.getSqlMapper();
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("weight_value", 30);
        try { 
            List<String> list = client.queryForList("query_search",map);
            System.out.println(list.size());
        }
        catch (SQLException e) {
         
        }


使用 ibatis 2.1.6 版本执行有问题。搞了半天。发现时这个版本对存储过程支持有问题。
换成 2.3.4 问题解决。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics