Mybatis學習第21節 -- 擴展結果集
阿新 • • 發佈:2019-03-17
integer ack myba 1.0 子類 知識點 過程 註意 batis 大部分現實應用中我們並不需要把數據庫中的整行數據都拉出來, 所以要做擴展結果集
筆記: 在實際項目過程中, 先用逆向工程自動生成, 然後再做擴展結果集來滿足大部分的現實需要
本節內容應該註意擴展結果集的命名方式
測試
Java知識點 如果父類實現了某接口,子類也會繼承接口的實現
創建一個擴展類ShopCustom, (這樣命名可以和Shop在項目樹裏面排列在一起)
package io.github.coinsjack.pojo;
|
創建一個mapper接口 ShopMapperCustom
package io.github.coinsjack.dao;
|
創建對應的映射文件
<?xml version="1.0" encoding="UTF-8" ?>
<resultMap id="shopResultMap" type="ShopCustom">
|
@Test
|
結果
2018-12-29 11:33:32,656 [main] DEBUG [io.github.coinsjack.dao.ShopMapperCustom] - Cache Hit Ratio [io.github.coinsjack.dao.ShopMapperCustom]: 0.0 2018-12-29 11:33:33,128 [main] DEBUG [io.github.coinsjack.dao.ShopMapperCustom.getShopById] - ==> Preparing: select `shop_id`, `shop_name`, `shop_desc` from tb_shop where `shop_id` = ? 2018-12-29 11:33:33,237 [main] DEBUG [io.github.coinsjack.dao.ShopMapperCustom.getShopById] - ==> Parameters: 29(Integer) 2018-12-29 11:33:33,309 [main] DEBUG [io.github.coinsjack.dao.ShopMapperCustom.getShopById] - <== Total: 1 ShopCustom{shopName=‘暴漫奶茶店‘, shopDesc=‘過來喝喝就知道啦,你是我的奶茶‘} |
Java知識點 如果父類實現了某接口,子類也會繼承接口的實現
Mybatis學習第21節 -- 擴展結果集