- mybatis使用union的坑
需要注意的是union上下查詢字段名稱需要一致。最後將查詢的結果作爲臨時表進行查詢。否則,mybatis在進行插件改寫會認爲這是兩個SQL。select * from ( select wod.Qty as qty,wod.Title as title,wod.Spec as spec,wod.TypeId as typeId,wod.PId as pid, wps.productName,wps.productNum,wod.OrderId,wod.OrderNum from order_detail wod left join ( select proid,cnname as productName,casno as productNum from product_2 ) wps on wod.PId = wps.proid and wod.TypeId = 0 where OrderId = #{searchQuery.orderId} and wod.TypeId = 0 union select wod.Qty as qty,wod.Title as title,wod.Spec as spec,wod.TypeId as typeId,wod.PId as pid, wb.productName,wb.productNum,wod.OrderId,wod.OrderNum from order_detail wod left join ( select Id,concat('北京市',Bnccid) as productNum,productName from product_1 ) wb on wod.PId = wb.Id and wod.TypeId = 3 where OrderId = #{searchQuery.orderId} and wod.TypeId = 3 ) t where t.productName like concat('%',#{searchQuery.productName},'%')
- mybatis在使用sqlserver查詢主鍵的坑
如果sqlserver在設置主鍵自增後,則不可以通過程序設置主鍵。可以通過以下sql獲取下一個自增主鍵:select ident_current('tablename') + 1
- getter/setter方法
切記符合駝峯轉換命名規範。
MybatisPlus整合SqlServer遇到的坑
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.