mybatis foreach 取不到值 为null

新手上路,请多包涵

mybatis foreach 取不到值

我的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=")">
                #{item,jdbcType=INTEGER}
            </foreach>
        </if>
        <if test="type != null and type != ''">
            AND ma.type = #{type,jdbcType=VARCHAR}
        </if>
        <if test="width != null and width != 0">
            AND ma.width = #{width,jdbcType=INTEGER}
        </if>
        <if test="height != null and height != 0">
            AND ma.height = #{height,jdbcType=INTEGER}
        </if>
        <if test="fileSize != null and fileSize != 0">
            AND ma.fileSize <![CDATA[ <= ]]> #{fileSize,jdbcType=INTEGER}
        </if>
    </select>

请求对象
图片描述

sql语句打印
图片描述

为啥取不到值呢?
图片描述

阅读 8.9k
2 个回答

,是逗号吧,换成.试试(#{item,jdbcType=INTEGER})

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题