<resultMap id="cl" type="com.ding.entity.mysql.TaskComment"> <result property="id" column="id"/> <result property="userName" column="user_name"/> <collection property="taskCommentUserList" ofType="com.ding.entity.mysql.TaskCommentUser"> <result property="userName" column="oName"/> <result property="userId" column="oId"/> </collection> <collection property="taskCommentImgList" ofType="com.ding.entity.mysql.TaskCommentImg"> //名称相同取别名 column与别名对应 <result property="url" column="iUrl"/> <result property="name" column="iName"/> </collection> </resultMap> <select id="getTaskComment" resultMap="cl"> SELECT //名称相同取别名 o.*,cu.user_name oName,cu.user_id oId,ci.name iName,ci.url iUrl from task_comment o left join task_comment_user cu on o.id = cu.comment_id left join task_comment_img ci on o.id = ci.comment_id where o.task_id=#{id} </select>
mybatis 一对多 collection标签
最新推荐文章于 2023-09-20 10:00:00 发布