第一种写法
使用@Param(value="pinyin")
List<EmployeeinfoCustom> selectEmpListByPinYin(@Param(value="pinyin")String pinyin)throws Exception;
<select id="selectEmpListByPinYin" parameterType="java.lang.String" resultType="com.hrm.entity.emp.EmployeeinfoCustom">
select * from employeeinfo
<where>
<if test="#{pinyin!=null}">
pinyin like "%"#{pinyin}"%"
</if>
</where>
</select>
第二种写法
List<EmployeeinfoCustom> selectEmpListByPinYin(String pinyin)throws Exception;
<select id="selectEmpListByPinYin" parameterType="java.lang.String" resultType="com.hrm.entity.emp.EmployeeinfoCustom">
select * from employeeinfo
<where>
<if test="#{_parameter!=null}">
pinyin like "%"#{_parameter}"%"
</if>
</where>
</select>
转载于:https://my.oschina.net/iiiiiSKY/blog/651381