mybatis踩坑 ——对服务是毁灭性的!


作者:空白

# #** 这两种sql有着巨大的坑,只要踩了,可能随时把你自己干走。**

<select id="listConnection" parameterType="java.util.Map" resultMap="ResultMap">
        SELECT
        A.CONN_ID,
        A.CONN_NO,
        A.STA_ID,
        A.RUN_MODE,
        A.SRV_ID,
        A.LINE_ID
        FROM CONN A 
        where 1=1 
		<if test="srvId!= null" >
		AND SRV_ID= #{srvId,jdbcType=DECIMAL}
		</if>
</select>
// 此处为使用 where 标签SQL
<select id="listConnection" parameterType="java.util.Map" resultMap="ResultMap">
        SELECT
        A.CONN_ID,
        A.CONN_NO,
        A.STA_ID,
        A.RUN_MODE,
        A.SRV_ID,
        A.LINE_ID
        FROM CONN A
		<where> 
			<if test="srvId!= null">
			 A.SRV_ID= #{srvId,jdbcType=DECIMAL}
			</if> 
			<if test="runMode!= null">
			AND  A.RUN_MODE= #{runMode,jdbcType=VARCHAR}
			</if>
		</where>
</select>
扫码或搜索:前沿科技
发送 290992
即可立即永久解锁本站全部文章