当前位置:Gxlcms > 数据库问题 > mybatis springmvc调用oracle存储过程,返回记录集

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

时间:2021-07-01 10:21:17 帮助过:1人阅读

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方法得到对象;

 

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

标签:

人气教程排行