如果把SQL写在类中或是注解中,当要取select count(*) .... 类型sql的返回值,直接指定函数的返回类型为int/long即可;

但对于把sql语句写在XML文件的情况,如果要取select count(*) .... 的返回值,必须要指明结果类型resultType="java.lang.Integer",否则程序报错。

 

Mapper类中函数:

int getMyNameCount(@Param("uid") long createrId,@Param("name") String name);

 

XML文件:

<select >

    select count(*) from ar_dictionary where name=#{name} and create_uid=#{uid}

</select>

END

相关文章:

  • 2022-12-23
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案