使用條件構(gòu)造器QueryWrapper,SQL語句不會拼接條件構(gòu)造器里面的語句。
老師您好,使用MP過程出bug無法解決,o(╥﹏╥)o?關(guān)鍵代碼如下: @Reference(version?=?"1.0.0") StoreContactService?storeContactService; QueryWrapper<StoreContactEntity>?storeContactEntityQueryWrapper?=?new?QueryWrapper<>(); storeContactEntityQueryWrapper.eq("store_id",?storeUserEntity.getId()); List<StoreContactEntity>?storeContactEntityList?=?storeContactService.list(storeContactEntityQueryWrapper);
打印的sql語句為:
SELECT id,product_id,specs_name,specs_content,product_price,original_price,status,sort_order,create_time,update_time FROM specs_type
==> Parameters:?
<==? ? Columns: id, product_id, specs_name, specs_content, product_price, original_price, status, sort_order, create_time, update_time
<==? ? ? ? Row: 1, 1, 規(guī)格1, 精品套餐1, 10.00, 10.00, 1, 1, 2020-09-05 22:22:38.0, null
<==? ? ? ? Row: 2, 1, 規(guī)格2, 精品套餐2, 12.00, 12.00, 1, 1, 2020-09-05 22:23:11.0, null
<==? ? ? ? Row: 3, 2, 規(guī)格1, 2套餐, 10.00, 10.00, 1, 1, 2020-09-10 17:27:56.0, null
<==? ? ? Total: 3
把product_id為2的也查詢出來了,乍一看代碼,SQL語句沒有把條件拼接上去。
以為是Service層出了問題,檢查之后發(fā)現(xiàn),項目中其他地方的getById,page分頁方法均有效,只有使用的條件構(gòu)造器的地方條件構(gòu)造器里的調(diào)用全部無效。
查看源碼發(fā)現(xiàn)eq第一個參數(shù)要傳true,但是默認(rèn)是true,不抱希望的去測試,果然不是這里的問題。
猜測可能和MP版本有關(guān),原MP版本為3.1.2,升到3.3.2,3.4.0結(jié)果相同。
打斷點進(jìn)入QueryWrapper里面,發(fā)現(xiàn)entity實體是空的,現(xiàn)在不知道怎么解決。
dubbo 2.5.3版本,springboot 1.5.6.RELEASE。
2020-09-13
你使用dubbo,應(yīng)該是通過rpc的方式調(diào)用遠(yuǎn)程項目的方法了,MP官網(wǎng)上關(guān)于條件構(gòu)造器是這樣說的“不支持以及不贊成在 RPC 調(diào)用中把 Wrapper 進(jìn)行傳輸”