久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

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

瀏覽:2日期:2023-10-21 17:08:39

批量修改代碼如下

<update 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 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í)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Mybatis 數(shù)據(jù)庫
相關(guān)文章:
主站蜘蛛池模板: 建昌县| 克什克腾旗| 汉沽区| 西宁市| 德令哈市| 荣昌县| 辽源市| 海丰县| 禹州市| 汝阳县| 龙门县| 辉南县| 梁山县| 年辖:市辖区| 扎赉特旗| 石河子市| 德格县| 云龙县| 湘西| 澜沧| 昆明市| 黑龙江省| 峨眉山市| 互助| 咸阳市| 景东| 商丘市| 故城县| 同德县| 磴口县| 根河市| 湖南省| 高碑店市| 郯城县| 澜沧| 潜江市| 弥渡县| 奉新县| 嘉善县| 边坝县| 长汀县|