首先看一下下面两个sql语句的区别: <select id="selectByNameAndPassword" parameterType="java.util.Map" resultMap="BaseResultMap"> select id, username, password, role from user where username = #{username,jdbcType=VARCHAR} and password =…
MyBatis中#{ }和${ }的区别详解 1.#将传入的数据当成一个字符串,会对自动传入的数据加一个 双引号. 例如order by #id#,如果传入的值是111,那么解析成sql时变为order by “111”,如果传入的值是id,在解析成sql为order by “id”. 其实原来sql语句通常写成order by #{id} 与order by #id#的效果 一样. 2.$将传入的数据直接显示在sql语句中.例如order by${id},如果 传入的值则解析成sql语句为or…