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 @   小大宇  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
点击右上角即可分享
微信分享提示