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>
原创文章,转载请说明出处,谢谢合作