第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我怎樣才能修改mysql更新方法?

我怎樣才能修改mysql更新方法?

富國滬深 2023-09-27 10:39:36
我想從 dto 列表更新 mysql 表,但有一些例外,比如語法問題,這是我的代碼:@Override  @Transactional  public void updateCustomCategory(List<ItemDto> itemDtoList) {    if (CollectionUtils.isNotEmpty(itemDtoList)) {      for (ItemDto itemDto : itemDtoList) {        Long l1CustomCategoryId = itemDto.getL1CustomCatId();        Long l2CustomCategoyId = itemDto.getL2CustomCatId();        StringBuilder query =                new StringBuilder(                        "update ItemDto item set item.l1CustomCategoryId = :l1CustomCategoryId and item.l2CustomCategoryId = :l2CustomCategoyId where itemId = :itemId");        Query q = this.em.createQuery(query.toString());        q.setParameter("l1CustomCategoryId", l1CustomCategoryId);        q.setParameter("l2CustomCategoyId", l2CustomCategoyId);        q.setParameter("itemId", itemDto.getItemId());        q.executeUpdate();      }    }  }和例外情況如下:    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: and near line 1, column 108 [update com.shopee.data.dto.brandseller.item.ItemDto item set item.l1CustomCategoryId = :l1CustomCategoryId and item.l2CustomCategoryId = :l2CustomCategoyId where itemId = :itemId]        at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]        at org.hibernate.hql.internal.ast.ErrorTracker.throwQueryException(ErrorTracker.java:93) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:296) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:188) ~[hibernate-core-5.3.7.Final.jar!/:5.3.7.Final]        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile
查看完整描述

1 回答

?
MMMHUHU

TA貢獻(xiàn)1834條經(jīng)驗 獲得超8個贊

您不使用ANDwith SET,而是用逗號分隔它們。正確的語法是

SET item.l1CustomCategoryId = :l1CustomCategoryId, item.l2CustomCategoryId = :l2CustomCategoyId


查看完整回答
反對 回復(fù) 2023-09-27
  • 1 回答
  • 0 關(guān)注
  • 121 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號