• mybatis springmvc调用oracle存储过程,返回记录集


    参考:

    http://bbs.csdn.net/topics/390866155

    辅助参考:

    http://www.2cto.com/kf/201307/226848.html

    http://blog.csdn.net/grhlove123/article/details/7549290

    在smm中,这样的controller编写方式是不一样的;

    存储过程:

    create or replace procedure pro_getchart(chart_cur out sys_refcursor) is
    
    begin
    
      open chart_cur for
        select * from dic_chart;
    
    end pro_getchart;

    MapperXML:

        <select id="getChartByPro" statementType="CALLABLE" parameterType="map" >
         <![CDATA[
             call pro_getchart(
            #{chart_cur,mode=OUT,jdbcType=CURSOR,javaType=java.sql.ResultSet,resultMap=com.stono.dao.server.chart.DicChartMapper.BaseResultMap}
            ) 
        ]]>
        </select>

    DAO Interface:

    package com.stono.dao.server.chart;
    
    import java.util.List;
    import java.util.Map;
    
    import com.stono.model.server.chart.DicChart;
    
    public interface DicChartMapper {
         
    
        List<DicChart> getChartByPro(Map<String, Object> map);
    }

    service :

    ......
    
    @Service("DicChartService")
    public class DicChartServiceImpl implements DicChartServiceI {
    
         
        @Autowired
        DicChartMapper dicChartMapper;
    
         
        @SuppressWarnings("unchecked")
        @Override
        public List<DicChart> getChartByPro() { 
            Map<String, Object> map = new HashMap<String, Object>();
            dicChartMapper.getChartByPro(map);
            return (List<DicChart>) map.get("chart_cur");
        }
    
    }

    Controller:

    ......
    
    @Controller
    @RequestMapping("/DicChart")
    public class DicChartController {
    
        @Autowired
        DicChartServiceI chartServiceI;
     
    
        @RequestMapping(value = "/getChartByPro")
        @ResponseBody
        List<DicChart> getChartByPro() {
            return chartServiceI.getChartByPro();
        }
    }

    就是在调用Mapper的时候使用map参数,调用结束之后再用get方法得到对象;

     如果返回的是一个字段,也要用这样的方式,返回的是对象;然后再从对象中获取该属性;

  • 相关阅读:
    android 如何引用jar包
    ExoPlayer + 边缓存边播放
    adb打开系统设置的命令
    android 8.0 适配(总结)
    android 7.0适配(总结)
    android 6.0适配(总结)
    常用adb命令
    nginx 简介
    Marshmallow 的用法
    python 自动生成当前项目的requirements文件
  • 原文地址:https://www.cnblogs.com/stono/p/4664803.html
Copyright © 2020-2023  润新知