亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Mybatis批量修改時(shí)出現(xiàn)報(bào)錯(cuò)問題解決方案

 更新時(shí)間:2020年11月09日 15:36:17   作者:cqy19951026  
這篇文章主要介紹了Mybatis批量修改時(shí)出現(xiàn)報(bào)錯(cuò)問題解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

批量修改代碼如下

<update id="UPDATE_HOTEL_REAL_TIME_PRICE" parameterType="java.util.List">
    <foreach collection="list" item="item" index="index" separator=";">
      UPDATE VST_HOTEL_REAL_TIME_PRICE
      <set>
        <if test="item.realTimePrice1 != null">
          REAL_TIME_PRICE1 = #{item.realTimePrice1},
        </if>
        <if test="item.realTimePrice2 != null">
          REAL_TIME_PRICE2 = #{item.realTimePrice2},
        </if>
        <if test="item.realTimeRemain1 != null">
          REAL_TIME_REMAIN1 = #{item.realTimeRemain1},
        </if>
        <if test="item.realTimeRemain2 != null">
          REAL_TIME_REMAIN2 = #{item.realTimeRemain2},
        </if>
        UPDATE_TIME = NOW()
      </set>
      WHERE PRODUCT_ID = ${item.productId}
     </foreach>
   </update>

今天在使用mybatis批量修改時(shí)報(bào)錯(cuò),錯(cuò)誤為sql語句錯(cuò)誤:

開始檢查xml中代碼:

<update id="updateTypeList" parameterType="list">
    <foreach collection="list" item="type" index="index" separator=";">
      UPDATE t_type
      <set>
        <if test="type.name != null">
          t_name = #{type.name}
        </if>
      </set>
      where t_id = #{type.id}
    </foreach>
  </update>

感覺并沒有錯(cuò)誤,把錯(cuò)誤語句復(fù)制到Navicat上能正常運(yùn)行,于是網(wǎng)上查找了一下需要在url語句中添加allowMultiQueries=true,添加后成功運(yùn)行。

Mysql中allowMultiQueries=true作用:

1.可以在sql語句后攜帶分號(hào),實(shí)現(xiàn)多語句執(zhí)行。

2.可以執(zhí)行批處理,同時(shí)發(fā)出多個(gè)SQL語句

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論