在使用MyBatis的动态SQL功能时,可能会出现单参数方法不执行或者抛出该属性没有get、set方法的异常。
该问题的解决方法是:
在Mapper接口中通过 @Param 来标记该参数即可。
public List<Student> getWithDynamicSql(@Param(value="address")String address);
<select id="getWithDynamicSql" resultMap="wylMap">
select * from student
where age = 22
<if test="address != null">
and address like #{address}
</if>
</select>