最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MyBatis實(shí)現(xiàn)多表聯(lián)合查詢r(jià)esultType的返回值

 更新時(shí)間:2022年03月10日 17:17:23   作者:aloofAnd  
這篇文章主要介紹了MyBatis多表聯(lián)合查詢r(jià)esultType的返回值,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

多表聯(lián)合查詢r(jià)esultType的返回值

一般數(shù)據(jù)按參數(shù)類型返回

<select id="queryCarIdList" resultType="long">
? ? ? ? select id from t_car_car
</select>
? <select id="queryDept" resultType="string">
? ? ? ? SELECT deptname FROM t_car_run where deptid = #{deptid} GROUP BY deptname
? ? </select>

根據(jù)某字段查詢

返回的類型是實(shí)體類,因?yàn)椴樵兘Y(jié)果數(shù)據(jù)均為實(shí)體類中字段的數(shù)據(jù)

<select id="queryNumber" resultType="io.renren.modules.generator.entity.TCarRunEntity">
? ? ? ? select number from t_car_car where id = #{carid}
</select>

查詢結(jié)果為多條記錄,存放在list中返回

返回的類型是實(shí)體類,因?yàn)椴樵兘Y(jié)果數(shù)據(jù)均為實(shí)體類中字段的數(shù)據(jù)

<select id="queryCar" resultType="io.renren.modules.generator.entity.TCarCarEntity">
? ? ? ? select * from t_car_car
</select>

多表聯(lián)合查詢

  • t_car_car
  • t_car_driver
  • t_car_cardriver

t_car_cardriver存放的兩個(gè)字段分別是t_car_car和t_car_driver的主鍵id

解決方案

1.resultType的返回類型是java.util.Map

返回得到的是List中存放的所有數(shù)據(jù)

<select id="queryDriver" resultType="java.util.Map">
? ? ? ? select driverid from t_car_cardriver where carid = #{id}
</select>

2.新建一個(gè)實(shí)體類

里面存放的是查詢結(jié)果里需要的字段名

// TCarCarDriver
private Long carid;
private Long driverid;

返回類型為該實(shí)體類

<select id="queryDriver" resultType="TCarCarDriver">
? ? ? ? select driverid from t_car_cardriver where carid = #{id}
</select>

多表聯(lián)查,返回結(jié)果嵌套list

多層集合嵌套返回結(jié)果用resultMap,collection中再次使用resultMap

<resultMap id="chainVo" type="com.suncnpap.intelligentqa.vo.ChainVo">
? ? <id column="cid" property="id"/>
? ? <result column="access_key" property="accessKey"/>
? ? <result column="secret_key" property="secretKey"/>
? ? <result column="outer_chain_name" property="outerChainName"/>
? ? <result column="outer_chain_document" property="outerChainDocument"/>
? ? <collection property="intentionVos" ofType="com.suncnpap.intelligentqa.vo.ChainIntentionVo"
? ? ? ? ? ? ? ? resultMap="intentionVos"/>
</resultMap>
?
<resultMap id="intentionVos" type="com.suncnpap.intelligentqa.vo.ChainIntentionVo">
? ? <id column="iid" property="id"/>
? ? <result column="intention_name" property="intentionName"/>
? ? <collection property="questionVoList" ofType="com.suncnpap.intelligentqa.vo.MultiQuestionVo">
? ? ? ? <id column="qid" property="id"/>
? ? ? ? <result column="question" property="question"/>
? ? </collection>
? ? <collection property="wordVos" ofType="com.suncnpap.intelligentqa.vo.ChainIntentionWordVo">
? ? ? ? <id column="wid" property="id"/>
? ? ? ? <result column="word_slot" property="wordSlot"/>
? ? ? ? <result column="word_slot_miss_question" property="wordSlotMissQuestion"/>
? ? ? ? <result column="entity_type_ids" property="entityTypeIds"/>
? ? </collection>
</resultMap>
?
<select id="detail" resultMap="chainVo">
? ? select tc.id ? as tid,
? ? ? ? ? ?tci.id ?as iid,
? ? ? ? ? ?tciw.id as wid,
? ? ? ? ? ?tmq.id ?as qid,
? ? ? ? ? ?access_key,
? ? ? ? ? ?secret_key,
? ? ? ? ? ?outer_chain_name,
? ? ? ? ? ?outer_chain_document,
? ? ? ? ? ?intention_name,
? ? ? ? ? ?question,
? ? ? ? ? ?word_slot,
? ? ? ? ? ?word_slot_miss_question,
? ? ? ? ? ?entity_type_ids
? ? from t_chain tc
? ? ? ? ? ? ?left join t_chain_intention tci on tc.id = tci.chain_id
? ? ? ? ? ? ?left join t_chain_intention_word tciw on tci.id = tciw.intention_id
? ? ? ? ? ? ?left join t_multi_question tmq on tci.id = tmq.parent_id
? ? where tc.id = #{id}
? ? ? and tc.deleted = 0
</select>

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java中的線程安全問題詳細(xì)解析

    Java中的線程安全問題詳細(xì)解析

    這篇文章主要介紹了Java中的線程安全問題詳細(xì)解析,線程安全是如果有多個(gè)線程在同時(shí)運(yùn)行,而這些線程可能會同時(shí)運(yùn)行這段代碼,程序每次運(yùn)行結(jié)果和單線程運(yùn)行的結(jié)果是一樣的,而且其他的變量的值也和預(yù)期的是一樣的,此時(shí)我們就稱之為是線程安全的,需要的朋友可以參考下
    2023-11-11
  • Spring?boot整合jsp和tiles模板示例

    Spring?boot整合jsp和tiles模板示例

    這篇文章主要介紹了Spring?boot整合jsp模板和tiles模板的示例演示過程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-03-03
  • java實(shí)現(xiàn)識別二維碼圖片功能

    java實(shí)現(xiàn)識別二維碼圖片功能

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)識別二維碼圖片功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-04-04
  • Spring AOP事務(wù)管理的示例詳解

    Spring AOP事務(wù)管理的示例詳解

    這篇文章將通過轉(zhuǎn)賬案例為大家詳細(xì)介紹一下Spring AOP是如何進(jìn)行事務(wù)管理的,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
    2022-06-06
  • Mybatis-plus解決兼容oracle批量插入的示例詳解

    Mybatis-plus解決兼容oracle批量插入的示例詳解

    Mybatis-Plus 是一個(gè) MyBatis 的增強(qiáng)工具,提供無侵入、損耗小的 CRUD 操作,本文給大家介紹了Mybatis-plus解決兼容oracle批量插入,文中通過大家介紹的非常詳細(xì),需要的朋友可以參考下
    2024-11-11
  • 教你使用idea搭建ssm詳細(xì)教程(Spring+Spring Mvc+Mybatis)

    教你使用idea搭建ssm詳細(xì)教程(Spring+Spring Mvc+Mybatis)

    今天教大家使用idea搭建ssm詳細(xì)教程(Spring+Spring Mvc+Mybatis),文中有非常詳細(xì)的圖文介紹及代碼示例,對正在學(xué)習(xí)使用idea的小伙伴很有幫助,需要的朋友可以參考下
    2021-05-05
  • Java遍歷Map對象集合的六種方式代碼示例

    Java遍歷Map對象集合的六種方式代碼示例

    Java中的Map是一種鍵值對映射的數(shù)據(jù)結(jié)構(gòu),它提供了一些常用的方法用于獲取、添加、刪除和修改元素,下面這篇文章主要給大家介紹了關(guān)于Java遍歷Map對象集合的六種方式,需要的朋友可以參考下
    2024-02-02
  • SpringBoot使用AOP實(shí)現(xiàn)統(tǒng)一角色權(quán)限校驗(yàn)

    SpringBoot使用AOP實(shí)現(xiàn)統(tǒng)一角色權(quán)限校驗(yàn)

    這篇文章主要介紹了SpringBoot如何使用AOP實(shí)現(xiàn) 統(tǒng)一角色權(quán)限校驗(yàn),文中有詳細(xì)的代碼示例講解和操作流程,具有一定的參考價(jià)值,需要的朋友可以參考下
    2023-07-07
  • Spring?Boot虛擬線程Webflux在JWT驗(yàn)證和MySQL查詢性能比較

    Spring?Boot虛擬線程Webflux在JWT驗(yàn)證和MySQL查詢性能比較

    這篇文章主要為大家介紹了Spring Boot虛擬線程與Webflux在JWT驗(yàn)證和MySQL查詢上的性能比較,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-09-09
  • SpringBoot整合Netty的流程步驟

    SpringBoot整合Netty的流程步驟

    Netty是一個(gè)基于Java的開源網(wǎng)絡(luò)應(yīng)用框架,它提供了高性能、異步事件驅(qū)動的網(wǎng)絡(luò)編程能力,Netty旨在幫助開發(fā)者構(gòu)建高性能、高可靠性的網(wǎng)絡(luò)應(yīng)用程序,本文給大家詳細(xì)介紹了SpringBoot整合Netty的流程步驟,需要的朋友可以參考下
    2023-09-09

最新評論

卢龙县| 乳山市| 巴里| 探索| 云浮市| 德阳市| 宣威市| 汕尾市| 黄山市| 澎湖县| 交口县| 文成县| 唐山市| 大厂| 潼南县| 西宁市| 防城港市| 望奎县| 洪泽县| 云梦县| 双辽市| 浦县| 武宁县| 吕梁市| 理塘县| 鄂尔多斯市| 舒城县| 宁津县| 巫山县| 金溪县| 衡东县| 静乐县| 阳江市| 错那县| 平湖市| 安陆市| 武陟县| 宝山区| 马尔康县| 安新县| 牙克石市|