MyBatis中傳入引數為List集合的

bingguang1993發表於2018-03-06
 
   1.  <update id="deleteQnrCount" parameterType="java.util.List">
      update t_qs_qnr_count
      set
     COUNT_STS_CD='2'
      where COUNT_ID IN
           <foreach collection="list" item="item" separator=","
                open="(" close=")">
                #{item, jdbcType=VARCHAR}   
           </foreach>

   </update>

collection中為list,item中可以自定義

2.

 <!-- 批量插入問題 -->
    <insert id="insertQus" parameterType="java.util.List">
        insert into t_qs_qubank_questions
         (question_id,format)
        values
        <foreach collection="list" item="item" index="index" separator=",">
           (
             #{item.questionId,jdbcType=VARCHAR},
           
             #{item.format, jdbcType=VARCHAR}
           )
        </foreach>

    </insert>

傳入引數為List<Map<String,Object>>,獲取Map中的值就要item.key值


相關文章