When mybatis file mapping of the parameter value to obtain the difference between # and $

# {}: Is precompiled parameter to form the sql statement, to prevent sql injection.

$ {}: Value taken directly to the assembly sql statement.

E.g:

select * from employee where id = #{id}

After converted to:

select * from employee where id = ?

For this:

select * from employee where id = ${id}

After converted to:

select * from employee where id = 2

In most cases, we should use # {}.

Native jdbc does not support local placeholders we can use $ {} of values.

Guess you like

Origin www.cnblogs.com/xiximayou/p/12210347.html