配置文件:
<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;