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

        当方法的返回值是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'。


猜你喜欢

转载自blog.csdn.net/yanluandai1985/article/details/80847364
今日推荐