mybatis select查询使用返回结果为resultMap

<select id="findPageObjects" resultMap="sysUserMap">
  select * from sys_users
  where id = #{id}
  order by createTime desc
  limit #{startIndex},#{pageSize}
</select>
<resultMap type="com.demo.vo.SysUserDeptResult"
      id="sysUserMap">
  <!--说明:对于此值对象而言
    1.直接量类型的值可以通过set方法直接赋值
    2.对象类型的值可以通过再次查询进行数据封装-->
    
   <association property="sysDept"  //对应上面resultMap
          column="deptId"    //对应上面查到的数据中的部门ID,根据这个id在进行部门查询
          select="com.demo.dao.SysDeptDao.findById">  //在dao 接口里面找到对应的部门信息查询方法
   </association>  <!--开启二次查询,基于部门Id查询部门信息-->

</resultMap>

 

posted @ 2019-09-06 17:46  我爱si搬砖  阅读(3197)  评论(0编辑  收藏  举报