Mybatis query sql passes in a string, int and other basic data types as parameters,
It needs to be written as follows, no matter what the parameter name is, it must be changed to "_parameter"
as follows:
1 <select id="findByName" parameterType="string" resultType="com.domain.entity.FactoryEntity"> 2 SELECT * FROM T_FACTORY WHERE F_NAME LIKE "%${_parameter}%" 3 </select>
At the same time, the distinction between # and $ should be distinguished
#{}: resolves to a parameter marker for a JDBC prepared statement, and a #{ } resolves to a parameter placeholder.
${}: is just a pure string replacement, variable replacement will be done during dynamic SQL parsing.
name-->cy
eg: select id,name,age from student where name=#{name} -- name='cy'
select id,name,age from student where name=${name} -- name=cy