MyBatis调用Oracle存储过程
1、无输入和输出参数的存储过程
2、带有输入和输出参数的存储过程
3、返回游标的存储过程
mybatis中的配置文件代码
<resultMap type="java.util.HashMap" id="cursorMap">
</resultMap>
<select id="paging" parameterType="java.util.Map" statementType="CALLABLE">
{CALL EXTRA_WORK_APPLY_DB(
#{USER_ID,mode=IN,jdbcType=VARCHAR},
#{PROC_DEF_ID,mode=IN,jdbcType=VARCHAR},
#{START_NUM,mode=IN,jdbcType=VARCHAR},
#{END_NUM,mode=IN,jdbcType=VARCHAR},
#{SUCESS_FLAG,mode=OUT,jdbcType=INTEGER},
#{SUCESS_MSG,mode=OUT,jdbcType=VARCHAR},
#{V_CURSOR,mode=OUT,jdbcType=CURSOR,resultMap=cursorMap}
)}
</select>
JAVA DAO接口定义的接口方法
public interface IOvertimeDAO { public void paging(Map<String, Object> query);
}
JAVA ServiceImpl中对返回游标的处理
public List<Map<String, Object>> paging(Map<String, Object> query) {
query.put("USER_ID", Util.getInstance().getUserInfo(ServletActionContext.getRequest()).getUserID());
query.put("PROC_DEF_ID", "Extra-workApplicationFlow");
query.put("V_CURSOR", OracleTypes.CURSOR);
this.overtimeDAO.paging(query);
List<Map<String, Object>> result = (List<Map<String, Object>>)query.get("V_CURSOR");
return result;
}