mybatis in xml sql statement parameters passed with different parameters {#} is not the same

For incoming parameters, such as query

--------------------  select username,pwd from users where username=#{} or pwd=#{}  ---------------------

In both # {} The parameters depending on the method you write the query parameters differ

For example, such an approach is the following:

public Users selectUserByUsernameOrPwd(String username,String pwd){..}

Because the two parameters are String, # {} therefore two parameters in the query may be

Method One: arg0, arg1

Method Two: param1, param2

Annotations can also be added in the query method:

public Users selectUserByUsernameOrPwd(@Param("realname")String username,@Param("realpwd")String pwd){..}

Then written in the query:

select username,pwd from users where username=#{realname} or pwd=#{realpwd}

If your method is the following wording:

public Users selectUserByUsernameOrPwd(Users users){..}

So this can be written in the sql statement # {} corresponding attributes correspond to Users

select username,pwd from users where username=#{username} or pwd=#{pwd}

Guess you like

Origin www.cnblogs.com/toomucherror/p/10995628.html