数据库
首页 > 数据库> > 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都不行

标签:map,endTime,column,mybatis,Result,Oracle,注解,property,resps
来源: https://blog.csdn.net/qq_41890624/article/details/122702865