日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

collection 和association 的区别?

發(fā)布時(shí)間:2024/4/13 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 collection 和association 的区别? 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

association:一對(duì)一

<!-- 另一種聯(lián)合查詢(一對(duì)一)的實(shí)現(xiàn),但是這種方式有“N+1”的問(wèn)題--> <resultMap id="BlogWithAuthorQueryMap" type="com.leon.domain.associate.BlogAndAuthor"><id column="bid" property="bid" jdbcType="INTEGER"/><result column="name" property="name" jdbcType="VARCHAR"/><association property="author" javaType="com.leon.domain.Author"column="author_id" select="selectAuthor"/> <!-- selectAuthor 定義在下面--> </resultMap>

collection:一對(duì)多、多對(duì)多

<!-- 查詢文章帶評(píng)論的結(jié)果(一對(duì)多) --> <resultMap id="BlogWithCommentMap" type="com.leon.domain.associate.BlogAndComment"extends="BaseResultMap" ><collection property="comment" ofType="com.leon.domain.Comment"><id column="comment_id" property="commentId" /><result column="content" property="content" /></collection> </resultMap> <!-- 按作者查詢文章評(píng)論的結(jié)果(多對(duì)多) --> <resultMap id="AuthorWithBlogMap" type="com.leon.domain.associate.AuthorAndBlog" ><id column="author_id" property="authorId" jdbcType="INTEGER"/><result column="author_name" property="authorName" jdbcType="VARCHAR"/><collection property="blog" ofType="com.leon.domain.associate.BlogAndComment"><id column="bid" property="bid" /><result column="name" property="name" /><result column="author_id" property="authorId" /><collection property="comment" ofType="com.leon.domain.Comment"><id column="comment_id" property="commentId" /><result column="content" property="content" /></collection></collection> </resultMap>

?

?

?

總結(jié)

以上是生活随笔為你收集整理的collection 和association 的区别?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。