使用Mybatis时mapper方法需要时动态SQL有且只有一个参数报错
使用Mybatis时mapper方法需要时动态SQL有且只有一个参数时,需要给这个唯一的参数设置别名(@Param(“别名”))
eg:
1 public interface UserMapper{
//@Param注解用于给参数取别名
//如果只有一个参数,并且在<if>里使用,则必须加别名
2 int SelectUserRows(@Param("userId")int userId); 3 }
使用Mybatis时mapper方法需要时动态SQL有且只有一个参数时,需要给这个唯一的参数设置别名(@Param(“别名”))
eg:
1 public interface UserMapper{
//@Param注解用于给参数取别名
//如果只有一个参数,并且在<if>里使用,则必须加别名
2 int SelectUserRows(@Param("userId")int userId); 3 }