MyBatis调用Oracle存储过程

1、无输入和输出参数的存储过程

2、带有输入和输出参数的存储过程

3、返回游标的存储过程

mybatis中的配置文件代码

 1     <resultMap type="java.util.HashMap" id="cursorMap">
 2     </resultMap>
 3     <select id="paging" parameterType="java.util.Map" statementType="CALLABLE">
 4         {CALL EXTRA_WORK_APPLY_DB(
 5             #{USER_ID,mode=IN,jdbcType=VARCHAR},
 6             #{PROC_DEF_ID,mode=IN,jdbcType=VARCHAR},
 7             #{START_NUM,mode=IN,jdbcType=VARCHAR},
 8             #{END_NUM,mode=IN,jdbcType=VARCHAR},
 9             #{SUCESS_FLAG,mode=OUT,jdbcType=INTEGER},
10             #{SUCESS_MSG,mode=OUT,jdbcType=VARCHAR},
11             #{V_CURSOR,mode=OUT,jdbcType=CURSOR,resultMap=cursorMap}
12         )}
13     </select>

 

JAVA DAO接口定义的接口方法

1 public interface IOvertimeDAO {
2     
3     public void paging(Map<String, Object> query);
4 }

 

JAVA ServiceImpl中对返回游标的处理

1     public List<Map<String, Object>> paging(Map<String, Object> query) {
2         query.put("USER_ID", Util.getInstance().getUserInfo(ServletActionContext.getRequest()).getUserID());
3         query.put("PROC_DEF_ID", "Extra-workApplicationFlow");
4         query.put("V_CURSOR", OracleTypes.CURSOR);
5         this.overtimeDAO.paging(query);
6         List<Map<String, Object>> result = (List<Map<String, Object>>)query.get("V_CURSOR");
7         return result;
8     }

 

posted on 2015-04-21 14:18  紫色诺言  阅读(656)  评论(0编辑  收藏  举报