<select id="getErrorTimes" resultType="Integer">
       SELECT ErrorTimes FROM `employee_sensitive`  WHERE `EmpId`=#{empId};
    </select>

上述XML中,ErrorTimes为Integer类型,在接口中我如下声明:

Integer getErrorTimes(@Param("empId") Integer empId);

大多数情况下是没有问题的,但是有一种情况会出问题,就是在empId会查出多个列时候,程序报错。

所以接口改为如下就正确:

List<Integer> getErrorTimes(@Param("empId") Integer empId);

这也说明了一个事情,ResultType支持一个值或者一个List将其封装。

相关文章:

  • 2021-12-09
  • 2021-11-13
  • 2022-12-23
  • 2021-11-26
  • 2021-11-27
  • 2021-07-21
  • 2021-08-29
猜你喜欢
  • 2021-07-24
  • 2022-01-10
  • 2022-12-23
  • 2021-09-11
  • 2021-05-17
  • 2021-10-08
相关资源
相似解决方案