mybatis怎么接收oracle存储过程的结果

其实无论是返回以下哪种类型,其实都是键值对对的形式

普通类型
oracle(即存储过程)
create or replace procedure testReturnResult(returnResult out varchar2)
as
begin
   returnResult :='返回结果';
end ;
java
service:
Map mm=new HashMap();
this.j1SchedulingDao.testReturnResult(mm);
System.out.println("returnResult:"+mm.get("returnResult"));

dao:
public void testReturnResult(Map mm) throws SQLException;
mybatis


游标类型
oracle(即存储过程)
create or replace procedure testReturnList(returnList out sys_refcursor)
as
begin
   open returnList for select *  from T_J1_SCHEDULING;
end ;
java
service:
Map mmap=new HashMap();
this.j1SchedulingDao.testReturnList(mmap);
List> returnList = (List>) mmap.get("returnList");

dao:
public void testReturnList(Map mm) throws SQLException;
mybatis


踩过的坑
  • The JDBC Type must be specified for output parameter. Parameter: returnResult 必须指定jdbcType
  • Parameters of type java.sql.ResultSet require a resultmap. 如果返回值是游标类型 必须指定resultmap
  • BaseResultMap is ambiguous in Result Maps collection (try using the full name including the namespace, or rename one of the entries) 需要指定包,指向对应的dao包 也就是当前的namespace.resultMap的id就可以了
[写博客只为记录,如有不对,还请各位大佬指出]

你可能感兴趣的:(mybatis怎么接收oracle存储过程的结果)