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>
原创文章,转载请说明出处,谢谢合作
标签:
Mybatis
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律