Mybatis查询二级评论SQL

 

 

 

 Mybatis查询评论

复制代码
 1     <select id="getCommentByID" resultMap="getCommentResultMap">
 2         SELECT com1.*,com2.*
 3         FROM itkb_comment_info com1 LEFT JOIN itkb_comment2_info com2 ON com1.id = com2.c2comment1Id
 4         WHERE com1.articleid=#{articleid}
 5     </select>
 6 
 7     <resultMap id="getCommentResultMap" type="com.example.demo.itkb.square.article.entity.Comment">
 8         <id property="id" column="id"/>
 9         <result property="articleid" column="articleid"/>
10         <result property="username" column="username"/>
11         <result property="commentDate" column="commentDate" />
12         <result property="commentContent" column="commentContent" />
13         <collection property="comment2" ofType="com.example.demo.itkb.square.article.entity.Comment2">
14             <id property="c2id" column="c2id"/>
15             <result property="c2comment1Id" column="c2comment1Id" />
16             <result property="c2username" column="c2username" />
17             <result property="c2commentDate" column="c2commentDate" />
18             <result property="c2commentContent" column="c2commentContent" />
19         </collection>
20     </resultMap>
复制代码

 

posted @   勤快的懒羊羊  阅读(187)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示