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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM