myabatis oracle 调用存储过程返回list结果集
来源:互联网 发布:2017淘宝充值网店 编辑:程序博客网 时间:2024/06/06 15:45
Mapper.xml 配置
<resultMap type="emp" id="empMap">
<id property="empno" column="empno"/>
<result property="ename" column="ename"/>
<result property="mgr" column="mgr"/>
<result property="job" column="job"/>
<result property="hiredate" column="hiredate"/>
<result property="sal" column="sal"/>
<result property="comm" column="comm"/>
</resultMap>
<!-- 调用存储过程返回结果集 -->
<select id="getEmps" parameterType="java.util.Map" statementType="CALLABLE">
<![CDATA[
call pro_emp(#{emps,mode=OUT,jdbcType=CURSOR,javaType=java.sql.ResultSet,resultMap=empMap}) ]]>
</select>
存储过程:
create or replace procedure pro_emp(cur_sys out sys_refcursor)
as
begin
open cur_sys for select empno, ename, job, mgr, hiredate, sal, comm, deptno
from tb_emp;
end;
IOperation接口里的方法 :
public interface IOperation {
void getEmps(Map<String, Object> param);
}
测试类:
public class Mytest {
private SqlSession sqlSession;
private IOperation mapper;
@Before
public void before(){
try {
SqlSessionFactory factory=MyBatisUtil.getSqlSessionFactory();
sqlSession=factory.openSession();
mapper=sqlSession.getMapper(IOperation.class);
System.out.println("start");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
@Test
public void getEmps(){
try {
Map<String, Object> param = new HashMap<String, Object>();
param.put("emps",OracleTypes.CURSOR);
mapper.getEmps(param);
List<Emp> depts =(List<Emp>)param.get("emps");
for (Emp emp : depts) {
System.out.println(emp.getEmpno()+" "+emp.getEname());
}
} catch (Exception e) {
System.out.println("getEmp: "+e.getMessage());
}
}
@After
public void after(){
System.out.println("close");
sqlSession.close();
}
}
结果:
start
DEBUG - Openning JDBC Connection
DEBUG - Created connection 8344960.
DEBUG - ooo Using Connection [oracle.jdbc.driver.T4CConnection@7f5580]
DEBUG - ==> Preparing: call pro_emp(?)
DEBUG - ==> Parameters:
123 liuzan
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER
close
- myabatis oracle 调用存储过程返回list结果集
- 调用Oracle存储过程返回结果集
- ssh调用存储过程,并返回list结果集
- ASP 调用 ORACLE存储过程并返回结果集
- C#调用ORACLE存储过程返回结果集及函数
- C#调用ORACLE存储过程返回结果集及函数
- C#调用ORACLE存储过程返回结果集及函数
- C#调用ORACLE存储过程返回结果集及函数
- C#调用ORACLE存储过程返回结果集及函数
- C#调用ORACLE存储过程返回结果集及函数
- C#调用ORACLE存储过程返回结果集及函数
- ASP 调用 Oracle 存储过程返回结果集
- C#调用ORACLE存储过程返回结果集及函数
- ado.net oledb 调用oracle存储过程返回结果集
- c#调用oracle存储过程返回结果集及函数
- C#与java调用Oracle存储过程返回结果集
- C#调用ORACLE存储过程返回结果集及函数
- Java 调用 Oracle 存储过程返回结果集
- Python爬虫一(入门综述、基础)
- 196. Delete Duplicate Emails#1
- 存取器方法、属性声明
- 196. Delete Duplicate Emails#1
- 【XML】 (3)语法规则
- myabatis oracle 调用存储过程返回list结果集
- LightOJ 1289 LCM from 1 to n
- java基础(一)------基本数据类型
- 支付业务名词及释义大全
- (2)Window安装ArcGIS Server 10.2
- crontab任务计划
- 第几天?
- KafkaConsumer流程简述
- uva10652 Board Wrapping