mybatis 调用oracle中的存储过程返回结果集

配置文件:

<parameterMap type="map" id="testCallsql">
<parameter property="a" jdbcType="INTEGER" mode="IN"/>
<parameter property="b" jdbcType="CURSOR" mode="OUT" resultMap="testMap"/>
</parameterMap>
<resultMap type="com.mytest.entity.Course" id="testMap">
<result column="id" property="id"/>
<result column="cname" property="cname"/>
</resultMap>
<select id="testCall" parameterMap="testCallsql" statementType="CALLABLE">
{call p6(?,?)}
</select>

java代码:

@RequestMapping("calltest")
    public @ResponseBody
    Map<String, Object> calltest(Integer a) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("a", a);
        map.put("b", "");
        testServiec.testCall(map);
        return map;
    }

public class Course {

    private Integer  id;
    private String cname;
    
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getCname() {
        return cname;
    }
    public void setCname(String cname) {
        this.cname = cname;
    }
    
}

oracle 表及过程

create table AA_COURSE
(
  id    NUMBER not null,
  cname VARCHAR2(20) not null
)
create or replace procedure p6(a in int,b out sys_refcursor )is
begin
  open b for select * from aa_course;
end;


转载于:https://my.oschina.net/u/1582930/blog/357114

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值