MyBatis注意事项(返回值是Integer,操作IN语句注意事项,插入空值)
1. 当方法的返回值是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. 所以,正确的Mybatis配置,要加上 resultType = ‘integer’。 /** * 获取表里所有记录的数量 * * @param statement 要执行的SQL语句的标记,对应的是Mybatis中的id的值 * @return 表里所有记录的数量 */ Integer getCount(String statement); 所以,正确的Mybatis配置,要加上 resultType = ‘integer’。 2. 操作IN语句注意事项 当用到IN语句时,Dao层接口中传递的是 List<String> , Mybatis解析成 id IN (" 221 , 223,