更改前語句
"querymyordersdonotuse" resultmap=
"myordersvo"
>
select
o.id as orderid,
o.created_time as createdtime,
o.pay_method as paymethod,
o.real_pay_amount as realpayamount,
o.post_amount as postamount,
os.order_status as orderstatus,
oi.item_id as itemid,
oi.item_name as itemname,
oi.item_img as itemimg,
oi.item_spec_id as itemspecid,
oi.item_spec_name as itemspecname,
oi.buy_counts as buycounts,
oi.price as price
from
`orders` o
left join
order_status os
ono.id = os.order_id
left join
order_items oi
onoi.order_id = o.id
where
o.user_id = #
ando.is_delete =
0<
if test=
"parammap.orderstatus != null"
>
and os.order_status = #
>
order by o.updated_time asc
<
/select>
將巢狀查詢的sql拆開,首先在resultmap標籤中的collection 標籤中新增屬性,
select=「getsubitems」 代表查詢方法的id
column=「orderid」 代表傳入查詢方法的引數
"suborderitemlist" select=
"getsubitems" column=
"orderid"
oftype=
"com.yf.pojo.vo.mysuborderitemvo"
>
"itemid" property=
"itemid"
/>
"itemname" property=
"itemname"
/>
"itemimg" property=
"itemimg"
/>
"itemspecid" property=
"itemspecid"
/>
"itemspecname" property=
"itemspecname"
/>
"buycounts" property=
"buycounts"
/>
"price" property=
"price"
/>
<
/collection>
將sql語句拆分,分別查詢資料
"querymyorders" resultmap=
"myordersvo"
>
select
o.id as orderid,
o.created_time as createdtime,
o.pay_method as paymethod,
o.real_pay_amount as realpayamount,
o.post_amount as postamount,
os.order_status as orderstatus
from
`orders` o
left join
order_status os
ono.id = os.order_id
where
o.user_id = #
ando.is_delete =
0<
if test=
"parammap.orderstatus != null"
>
and os.order_status = #
>
order by o.updated_time asc
<
/select>
"getsubitems" parametertype=
"string" resulttype=
"com.yf.pojo.vo.mysuborderitemvo"
>
select
oi.item_id as itemid,
oi.item_name as itemname,
oi.item_img as itemimg,
oi.item_spec_id as itemspecid,
oi.item_spec_name as itemspecname,
oi.buy_counts as buycounts,
oi.price as price
from
order_items oi
where
oi.order_id = #
<
/select>
PageHelper分頁外掛程式
com.github.pagehelper pagehelper 5.1.2 1.在mybatis中配置 此時並沒有spring來管理mybatis 2.使用spring容器管理 此時mybatis已交由spring容器管理 1.helperdialect 分頁外掛程式會自動檢測當前的資料庫鏈結,自...
外掛程式分頁 pageHelper
步驟 1.導包 3.serivce中,給到具體的分頁的頁碼page,每頁條數 size 4.controller中把得到的資料儲存到pageinfo。5.到達頁面在pom檔案中導包 com.github.pagehelper pagehelper 5.1.2 mysql true 在service層...
分頁外掛程式PageHelper
com.github.pagehelper pagehelper 4.1.0 啟動位址,埠 server.port 8088 資料庫連線池配置 spring.datasource.type com.alibaba.druid.pool.druiddatasource spring.datasourc...