MyBatis-------返回值是对象类型需要显示指明

        当方法的返回值是Integer类型时候,需要指明ResultType属性。

        我今天就没加,我当时想,会不会自动装箱呢?结果哦,好气啊,炸了。

        错误信息为:

        org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped 

        Statement 'com.ssi.domains.leave.repository.LeaveRepository.getLeaveCount'.  

        It's likely that neither a Result Type nor a Result Map was specified.

          

        上代码:

    /**
     * 获取表里所有记录的数量
     *
     * @param statement 要执行的SQL语句的标记,对应的是Mybatis中的id的值
     * @return          表里所有记录的数量
     */
    Integer getCount(String statement);

            

        所以,正确的Mybatis配置,要加上 resultType = 'integer'。

更多MyBatis使用经验

         MyBaits操作经验目录贴

如果本系列文章对你有帮助,不妨请我喝瓶可乐吧!

你的打赏是对我最好的支持!

                    

posted @ 2022-07-17 12:13  小大宇  阅读(1)  评论(0编辑  收藏  举报