Mybatis foreach cannot get a value of null

mybatis foreach cannot get a value

my sql

    <select id="findByCustomerId" resultMap="BaseResultMap">
        SELECT ma.* FROM media_material_relation mr,media_material ma
        WHERE mr.material_id = ma.material_id
        <if test="customerIds != null">
            AND mr.customer_id IN
            <foreach item="item" index="index" collection="customerIds" open="(" separator="," close=")">
                -sharp{item,jdbcType=INTEGER}
            </foreach>
        </if>
        <if test="type != null and type != """>
            AND ma.type = -sharp{type,jdbcType=VARCHAR}
        </if>
        <if test="width != null and width != 0">
            AND ma.width = -sharp{width,jdbcType=INTEGER}
        </if>
        <if test="height != null and height != 0">
            AND ma.height = -sharp{height,jdbcType=INTEGER}
        </if>
        <if test="fileSize != null and fileSize != 0">
            AND ma.fileSize <![CDATA[ <= ]]> -sharp{fileSize,jdbcType=INTEGER}
        </if>
    </select>

request object

sql


Mar.09,2021

also encountered. There is a paging plug-in, can be used is ${item}, do not need to add jdbcType


, it is a comma, replace it. Try (- sharp {item,jdbcType=INTEGER})

Menu