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

Mybatis關(guān)聯(lián)查詢結(jié)果集對象嵌套的具體使用

 更新時間:2022年02月23日 09:47:45   作者:FANQIBU  
在查詢時經(jīng)常出現(xiàn)一對多”的關(guān)系,所有會出現(xiàn)嵌套對象的情況,本文主要介紹了Mybatis關(guān)聯(lián)查詢結(jié)果集對象嵌套的具體使用,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

在查詢時經(jīng)常出現(xiàn)一對多”的關(guān)系,所有會出現(xiàn)嵌套對象的情況,Mybatis在resultMap提供了collection標簽,本文適合有一定Mybatis基礎(chǔ)的讀者查閱

數(shù)據(jù)模型WeixinActivity2018User.java

public class WeixinActivity2018User ?implements Serializable{

? ? /** serialVersionUID*/
? ? private static final long serialVersionUID = -2740162776768956231L;

? ? private int id;
? ? private String nickname; ?//昵稱
? ? private String headurl; ? //頭像
? ? private String openid; ? ?//微信用戶OpenId
? ? private String unionid;
? ? private String phone; ? ? //用戶手機號
? ? private int count; ? ? ? ?//積攢數(shù)
? ? private String createtime;//創(chuàng)建時間
? ? private String uptime; ? ?//更新時間
? ? private List<WeixinActivity2018UserAssist> activity2018UserAssists;//點贊用戶信息

數(shù)據(jù)模型WeixinActivity2018UserAssist.java

public class WeixinActivity2018UserAssist ?implements Serializable{

? ? /** serialVersionUID*/
? ? private static final long serialVersionUID = -2740162776768956232L;

? ? private int aid;
? ? private int uid;
? ? private String nickname;
? ? private String headurl;
? ? private String openid;
? ? private String unionid;
? ? private String createtime;

WeixinActivity2018UserMapper.xml

? <resultMap id="BaseResultMap" type="com.lh.wx.model.WeixinActivity2018User">
? ? <id column="id" jdbcType="INTEGER" property="id" />
? ? <result column="openid" jdbcType="VARCHAR" property="openid" />
? ? <result column="unionid" jdbcType="VARCHAR" property="unionid" />
? ? <result column="phone" jdbcType="VARCHAR" property="phone" />
? ? <result column="nickname" jdbcType="VARCHAR" property="nickname" />
? ? <result column="headurl" jdbcType="VARCHAR" property="headurl" />
? ? <result column="count" jdbcType="INTEGER" property="count" />
? ? <result column="createtime" jdbcType="DATE" property="createtime" />
? ? <result column="uptime" jdbcType="DATE" property="uptime" />
? ? <collection ?property="activity2018UserAssists" ?ofType="com.lh.wx.model.WeixinActivity2018UserAssist">
? ? ? ? ? ? <id property="aid" column="aid" />
? ? ? ? ? ? ?<result column="uid" jdbcType="INTEGER" property="uid" />
? ? ? ? ? ? <result column="aopenid" jdbcType="VARCHAR" property="openid" />
? ? ? ? ? ? <result column="aunionid" jdbcType="VARCHAR" property="unionid" />
? ? ? ? ? ? <result column="anickname" jdbcType="VARCHAR" property="nickname" />
? ? ? ? ? ? <result column="aheadurl" jdbcType="VARCHAR" property="headurl" />
? ? ? ? ? ? <result column="acreatetime" jdbcType="DATE" property="createtime" />
? ? </collection>
? </resultMap>
? <sql id="Base_Column_List">
? ? openid,unionid,phone,nickname,headurl,count,createtime,uptime
? </sql>
? <insert id="insertActivity2018User" ?useGeneratedKeys="true" keyProperty="id" parameterType="com.lh.wx.model.WeixinActivity2018User" >
? ? insert into t_weixin_activity_2018_user (openid,unionid,phone,nickname,headurl,createtime,uptime)
? ? values (
? ? ? ? #{openid,jdbcType=VARCHAR},#{unionid,jdbcType=VARCHAR},#{phone,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR}, #{headurl,jdbcType=VARCHAR},now(),now()
? ? )
? </insert>
? ? <select id="selectTalCount" resultType="java.lang.Integer" ?parameterType="java.util.Map">
? ? ? ? SELECT ?count(twau.id)
? ? ? ? from ?t_weixin_activity_2018_user twau
? ? ? ? <if test="openid != '' and openid != null">
? ? ? ? ? ? and twau.openid = #{openid}
? ? ? ? </if>
? ? ? ? <if test="id != 0 and id != null">
? ? ? ? ? ? and twau.id = #{id}
? ? ? ? </if>
? ? ? ? <if test="phone != '' and phone != null">
? ? ? ? ? ? and twau.phone = #{phone}
? ? ? ? </if>
? ? </select>
? ? <select id="queryActivity2018User" parameterType="java.util.Map" resultMap="BaseResultMap" >
? ? ? ? SELECT?
? ? ? ? ?twau.id,twau.openid, twau.unionid, twau.phone, twau.nickname, twau.headurl, twau.count,date_format( twau.createtime, '%Y-%m-%d %H:%m:%s') as createtime,date_format( twau.uptime, '%Y-%m-%d %H:%m:%s') as uptime
? ? ? ? ,twaua.aid,twaua.uid,twaua.openid as aopenid,twaua.unionid as aunionid,twaua.nickname as anickname,twaua.headurl as aheadurl,date_format(twaua.createtime, '%Y-%m-%d %H:%m:%s') as acreatetime ,
? ? ? ? twaua.phone as aphone
? ? ? ? from ?t_weixin_activity_2018_user twau LEFT ?JOIN t_weixin_activity_2018_user_assist twaua on twau.id=twaua.uid ?where 1=1
? ? ? ? <if test="openid != '' and openid != null">
? ? ? ? ? ? and twau.openid = #{openid}
? ? ? ? </if>
? ? ? ? <if test="id != 0 and id != null">
? ? ? ? ? ? and twau.id = #{id}
? ? ? ? </if>
? ? ? ? <if test="phone != '' and phone != null">
? ? ? ? ? ? and twau.phone = #{phone}
? ? ? ? </if>
? ? ? ? <if test="start != '' and start != null ?and start != 0">
? ? ? ? ? ? order by tlb.createtime desc limit ${start}, ${number}
? ? ? ? </if>
? </select>

到此這篇關(guān)于Mybatis關(guān)聯(lián)查詢結(jié)果集對象嵌套的具體使用的文章就介紹到這了,更多相關(guān)Mybatis關(guān)聯(lián)查詢對象嵌套 內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java基礎(chǔ)學習之字符串知識總結(jié)

    Java基礎(chǔ)學習之字符串知識總結(jié)

    今天帶著大家復習一下Java基礎(chǔ)知識-字符串,文中介紹的非常詳細,對初步學習Java或者復習Java的小伙伴們都很有幫助喲,需要的朋友可以參考下
    2021-05-05
  • Spring Boot數(shù)據(jù)庫鏈接池配置方法

    Spring Boot數(shù)據(jù)庫鏈接池配置方法

    這篇文章主要介紹了Spring Boot數(shù)據(jù)庫鏈接池配置方法,需要的朋友可以參考下
    2017-04-04
  • Java線程池的幾種實現(xiàn)方法和區(qū)別介紹實例詳解

    Java線程池的幾種實現(xiàn)方法和區(qū)別介紹實例詳解

    本篇文章主要介紹了Java線程池的幾種實現(xiàn)方法和區(qū)別,需要的朋友可以參考
    2017-04-04
  • 對Mybatis?Plus中@TableField的使用正解

    對Mybatis?Plus中@TableField的使用正解

    這篇文章主要介紹了對Mybatis?Plus中@TableField的使用正解,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-01-01
  • java基于嵌入式Tomcat的War包啟動器

    java基于嵌入式Tomcat的War包啟動器

    本文主要介紹了java基于嵌入式Tomcat的War包啟動器,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-07-07
  • RestTemplate對HttpClient的適配源碼解讀

    RestTemplate對HttpClient的適配源碼解讀

    這篇文章主要為大家介紹了RestTemplate對HttpClient的適配源碼解讀,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-10-10
  • MyBatis Mapper.xml中的命名空間及命名方式

    MyBatis Mapper.xml中的命名空間及命名方式

    這篇文章主要介紹了MyBatis Mapper.xml中的命名空間及命名方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • 解決springboot集成swagger碰到的坑(報404)

    解決springboot集成swagger碰到的坑(報404)

    這篇文章主要介紹了解決springboot集成swagger碰到的坑(報404),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-06-06
  • JPA中@ElementCollection使用示例詳解

    JPA中@ElementCollection使用示例詳解

    在JPA中,@ElementCollection注解主要用于映射集合屬性,例如List、Set或數(shù)組等集合屬性,以及Map結(jié)構(gòu)的集合屬性,每個屬性值都有對應(yīng)的key映射,這篇文章主要介紹了JPA中@ElementCollection使用,需要的朋友可以參考下
    2023-11-11
  • SpringBoot整合FastJson過程解析

    SpringBoot整合FastJson過程解析

    這篇文章主要介紹了SpringBoot整合FastJson過程解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-10-10

最新評論

阿巴嘎旗| 岢岚县| 许昌市| 吉水县| 苏州市| 临桂县| 马龙县| 双流县| 鹰潭市| 龙海市| 上高县| 临沧市| 咸丰县| 多伦县| 新乡市| 大庆市| 大港区| 祁门县| 宣威市| 安庆市| 大冶市| 桑日县| 镇巴县| 安西县| 元朗区| 平乡县| 沅陵县| 丹巴县| 洛宁县| 胶南市| 河池市| 武宣县| 河源市| 竹溪县| 崇州市| 罗田县| 彰武县| 萍乡市| 兴安盟| 仁布县| 房山区|