C/C++教程

mybatis 注解调用Oracle存储过程

本文主要是介绍mybatis 注解调用Oracle存储过程,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

看别人的博客试了半天注解调用一直报错,然后试了试xml里面写,成功了

就根据xml里面写的改成注解也是成功了

service层调用

    public List<QualityTestLogResp> logList(String logicId, String startTime, String endTime) {
        Map<String, Object> resps = new HashMap<>();
        resps.put("loginId", logicId);
        resps.put("startTime", startTime);
        resps.put("endTime", endTime);
        tbGxjhSjzjMapper.getLogList(resps);
        return Convert.toList(QualityTestLogResp.class, resps.get("list"));
    }

mapper

@Select("{call Pack_checkSpgl.PROC_QUERYCHECKTOTAL( " +
            " #{map.logicId, jdbcType=VARCHAR, mode=IN}, " +
            " #{map.startTime, jdbcType=VARCHAR, mode=IN}, " +
            " #{map.endTime, jdbcType=VARCHAR, mode=IN}, " +
            " #{map.list, jdbcType=CURSOR, mode=OUT, resultMap=resMap} " +
            ")}")
    @Options(statementType = StatementType.CALLABLE)
    @Results(
            id = "resMap",
            value = {
                    @Result(column = "xh", property = "xh"),
                    @Result(column = "logicid", property = "logicid"),
                    @Result(column = "zjgz", property = "zjgz"),
                    @Result(column = "zjjls", property = "zjjls"),
                    @Result(column = "hgjls", property = "hgjls"),
                    @Result(column = "bhgjls", property = "bhgjls"),
            }
    )
    List<QualityTestLogResp> getLogList(@Param("map") Map<String, Object> map);

这里需要注意的是,没有用到返回值,实际上的结果在map里面,像我上面第四个参数那样定义的,键就是list。return的List里面是空的,不会有结果集,但是也得用这个返回值,写void或者object都不行

这篇关于mybatis 注解调用Oracle存储过程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!