警惕Mybatis的foreach的的副作用
9月 10, 2014 |
Nix.Huang
假设有如下的mapper:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<select id=”testForeach” parameterType=”map” resultType=”Student”> Select * from student <where> <if test=”ID != null and ID != ‘’ ”> ID = #{ID} </if> <if test=” IDArr != null and IDArr.size()>0”> And ID IN <foreach collection="IDArr" open="(" separator="," close=")" item="ID"> ${ID} </foreach> </if> </where> </select> |
这个动态SQL很 […more]