/mybatis/src/main/java/sy/mapping/UserMapper.xml
<resultMap type="sy.model.User" id="userResultMap3" extends="BaseResultMap"> <collection property="groupUsers" javaType="list" ofType="sy.model.GroupUser"> <id column="groupuser_id" property="id" /> <result column="user_id" property="userid" /> <result column="group_id" property="groupid" /> <association property="groups" javaType="sy.model.Group"> <id property="id" column="groupid"/> <result property="groupname" column="group_name"/> </association> </collection> </resultMap> <select id="getAll3" resultMap="userResultMap3"> SELECT `user`.id, `user`.`name`, `user`.loginname, `user`.pwd, `user`.mobile, group_user.id groupuser_id , group_user.userid user_id, group_user.groupid group_id, `group`.id groupid, `group`.groupname group_name FROM `user` JOIN group_user ON `user`.id = group_user.userid JOIN `group` ON group_user.groupid = `group`.id </select>
|