1.解析Integer为0的属性,解析成空字符串
1 <if test="type != null and type != ''">
2 and type = #{type}
3 </if>
此时若type为Integer类型且值为0会出错
2.使用pageHelper时,别用参数pageNum和pageSize,会产生冲突
3.传入混合参数(多个不同类型的参数)
public List<User> selectUserInIDs(@Param("ids")List<Integer>
ids,@Param("user")User user);
<select id="selectUserInIDs" resultType="User">
select * from user
<if test="null != ids">
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and name = #{user.name}
</if>
</select>
使用@param来标注参数,引用对象类参数时还需加上对象
4.使用List时切勿赋值为null,会导致空指针异常,因为要防止集合调用size()等方法出现异常
5.<if test="list != null and list.size()>0"> </if>
使用动态sql使用集合作为参数应该这样判断
6.模糊查询时
可以使用concat(’%’,#{staff.name},’%’)这种
也可以"%"#{name}"%"切记使用双引号不是单引号