当前位置: 首页 > news >正文

周口市网站建设_网站建设公司_前端工程师_seo优化

推上网站,新网官方网站,彩票网站怎么做代理,建设局网站查询association分步查询 场景一 查询Employee的同时查询员工对应的部门 EmployeeDepartment 一个员工有与之对应的部门信息 Employee表: Department表#xff1a; public interface DepartmentMapper {public Department getDeptById(Integer id);}public interface EmployeeMap…association分步查询 场景一 查询Employee的同时查询员工对应的部门 EmployeeDepartment 一个员工有与之对应的部门信息 Employee表: Department表 public interface DepartmentMapper {public Department getDeptById(Integer id);}public interface EmployeeMapperPlus {public Employee getEmpByIdStep(Integer id);}!-- public Department getDeptById(Integer id); --select idgetDeptById resultTypecom.atguigu.mybatis.bean.Departmentselect id,dept_name departmentName from tb1_dept where id #{id}/selectresultMap idMyEmpStep typecom.atguigu.mybatis.bean.Employee!-- 1.先按照员工id查询员工信息--!-- 2.根据查询员工信息中的d_id值去部门表查出部门信息--!-- 3.部门设置到员工中--id columnid propertyid/idresult columnlast_name propertylastName/resultresult columnemail propertyemail/resultresult columngender propertygender/result!-- association定义关联对象的封装规则select:表明当前属性是调用select指定的方法查出的结果column:指定将哪一列的值传给这个方法流程:使用select指定的方法(传入column指定的这列参数的值)查出对象并封装给property指定的属性--association propertydept selectcom.atguigu.mybatis.dao.DepartmentMapper.getDeptByIdcolumnd_id/association/resultMap!-- public Employee getEmpByIdStep(Integer id);--select id getEmpByIdStep resultMapMyEmpStepselect * from tb1_employee where id #{id}/selectTestpublic void test03() throws IOException {SqlSessionFactory sqlSessionFactory getSqlSessionFactory();SqlSession sqlSession sqlSessionFactory.openSession();try{EmployeeMapperPlus mapper sqlSession.getMapper(EmployeeMapperPlus.class);Employee emp mapper.getEmpByIdStep(1);System.out.println(emp);System.out.println(emp.getDept());}finally {sqlSession.close();}}延迟加载 Employee Dept 我们每次查询Employee对象的时候都将一起查询出来 分段查询的基础上使用延迟加载 可以使部门信息在我们使用的时候再去查询 lazyLoadingEnabled aggressiveLazyLoading settingssetting namelazyLoadingEnabled valuetrue/setting nameaggressiveLazyLoading valuefalse//settings场景二 查询部门的时候将部门对应的所有员工信息也查询出来 public class Department {private Integer id;private String departmentName;private ListEmployee emps;}public interface DepartmentMapper {public Department getDeptByIdPlus(Integer id);}resultMap idMyDept typecom.atguigu.mybatis.bean.Departmentid columndid propertyid/idresult columndept_name propertydepartmentName/result!--collection定义关联集合类型的属性的封装规则ofType:指定集合里面元素的类型--collection propertyemps ofTypecom.atguigu.mybatis.bean.Employee !--定义这个集合中元素的封装规则--id columneid propertyid/idresult columnlast_name propertylastName/resultresult columnemail propertyemail/resultresult columngender propertygender/result/collection/resultMap!-- public Department getDeptByIdPlus(Integer id);--select idgetDeptByIdPlus resultMap MyDeptSELECT d.id did, d.dept_name dept_name ,e.id eid,e.last_name last_name,e.email email,e.gender genderFROM tb1_dept d LEFT JOIN tb1_employee e ON d.id e.d_id WHERE d.id #{id}/selectTestpublic void test04() throws IOException {SqlSessionFactory sqlSessionFactory getSqlSessionFactory();SqlSession sqlSession sqlSessionFactory.openSession();try{DepartmentMapper mapper sqlSession.getMapper(DepartmentMapper.class);Department deptByIdPlus mapper.getDeptByIdPlus(1);System.out.println(deptByIdPlus);System.out.println(deptByIdPlus.getEmps());}finally {sqlSession.close();}}扩展多列的值传递过去 将多列的值封装map传递 column{key1column1,key2column2} fetchType“lazy”表示使用延迟加载 lazy延迟 eager立即
http://www.ihoyoo.com/news/130942.html

相关文章:

  • 网站开发的风险属于网站seo分析什么软件
  • 下载站cms宁波网页美工培训
  • 深圳做网站最好的公司网站建设增长率
  • 信息类网站 wordpress怎么做网页小猪佩奇
  • 龙岩做网站开发价格网站做js跳转
  • 创建全国文明城市英语作文英文网站优化
  • 怎样制作公司网站网易企业邮箱服务器设置怎么填
  • 网站可以备案先提交类别后来改么只做彩票网站犯法吗
  • 做视频网站都需要什么港巢网站建设
  • 公司网站开发的流程厂里拿货开小加工厂
  • 网站没有备案是假的吗合肥经开区建设局网站
  • 如何判断网站有cdn加速wordpress酷炫特效
  • 工信部网站icp备案舟山网页设计
  • 百度怎么优化网站排名网店装修的意义
  • 做网站淮南wordpress 折叠内容
  • 请上传网站应用水印图片网站建设夬金手指排名壹陆
  • 自己做网站用中文为什么是乱码广告公司照片
  • 中山网站建设开发wordpress 非根目录
  • 自助商城网站建设网站 手机版 电脑版 怎么做
  • 东莞小学网站建设wordpress 总分类页
  • 网页设计与网站建设完全学习手册pdf什么网站建设比较好的
  • 做软装设计能用到的网站有哪些设计坞在线海报制作
  • 学校网站的建设目标是什么WordPress怎么做百度小程序
  • 建电影网站教程免费分销系统
  • 高港做网站银川网站建设联系电话
  • 网站建设公司发展理念珠海有什么好的互联网公司
  • 网站关键词优化系统设计方案
  • 网站备案 厦门商标域名查询官网
  • 广州建设工程造价管理站网站大连百度搜索排名优化
  • 不用付费不用登录的网站seo网站设计联系方式