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

摄影网站采用照片做宣传 版权费是多少会员卡管理系统免费版

摄影网站采用照片做宣传 版权费是多少,会员卡管理系统免费版,站优云网络公司,网站建设公司怎么找渠道Mybatis#xff1a;一对一查询映射处理 前言一、概述二、创建数据模型三、 问题四、解决方案1、方案一#xff1a;级联方式处理映射关系2、方案二#xff1a;使用association处理映射关系3、方案三#xff1a;分步查询 前言 本博主将用CSDN记录软件开发求学之路上亲身所得… Mybatis一对一查询映射处理 前言一、概述二、创建数据模型三、 问题四、解决方案1、方案一级联方式处理映射关系2、方案二使用association处理映射关系3、方案三分步查询 前言 本博主将用CSDN记录软件开发求学之路上亲身所得与所学的心得与知识有兴趣的小伙伴可以关注博主也许一个人独行可以走的很快但是一群人结伴而行才能走的更远 一、概述 MyBatis是一种流行的Java持久化框架它提供了灵活而强大的查询映射功能。在一些复杂的数据模型中一对一查询映射是一种常见的需求。本篇博客将详细介绍如何在MyBatis中处理一对一查询映射。 二、创建数据模型 假设我们有两张数据表员工表和部门表每个员工都只属于一个部门我们需要创建对应的Java数据模型。 Emp.java public class Emp {private Integer eid;private String empName;private Integer age;private String sex;private String email;private Dept dept;...}Dept.java public class Dept {private Integer did;private String deptName;private ListEmp emps;...}三、 问题 现在我们要查询员工信息以及员工所对应的部门信息我们应该如何做呢 四、解决方案 1、方案一级联方式处理映射关系 EmpMapper /*** description:获取指定员工的信息(包括部门)* author: Hey* date: 2022/7/4 8:58* param: [id]* return: com.ir.mybatis.pojo.Emp**/Emp getAllEmpAndDept(Param(eid) Integer eid); EmpMapper.xml resultMap idtitle1 typeEmpid propertyeid columneid/idresult propertyempName columnemp_name/resultresult propertyage columnage/resultresult propertysex columnsex/resultresult propertyemail columnemail/resultresult propertydept.did columndid/resultresult propertydept.deptName columndept_name/result /resultMapselect idgetAllEmpAndDept resultMaptitle1select * from t_emp left join t_dept on t_emp.did t_dept .did where t_emp.eid #{eid}/selectResultTest /*** description:获取指定员工的信息(包括部门)* author: Hey* date: 2022/7/4 8:56* param: []* return: void**/Testpublic void getAllEmpAndDept(){SqlSession sqlSession SqlSessionUtils.getSqlSession();EmpMapper mapper sqlSession.getMapper(EmpMapper.class);Emp emp mapper.getAllEmpAndDept(2);System.out.println(emp);//Emp{eid2, empName美羊羊, age32, sex女, email123qq.com}}2、方案二使用association处理映射关系 EmpMapper /*** description:获取指定员工的信息(包括部门)* author: Hey* date: 2022/7/4 8:58* param: [id]* return: com.ir.mybatis.pojo.Emp**/Emp getAllEmpAndDept(Param(eid) Integer eid); EmpMapper.xml resultMap idtitle1 typeEmpid propertyeid columneid/idresult propertyempName columnemp_name/resultresult propertyage columnage/resultresult propertysex columnsex/resultresult propertyemail columnemail/result!--association:处理多对一的映射关系property:需要处理多对的映射关系的属性名javaType:该属性的类型过程通过javaType运用反射确定其所有属性再将column一一准确赋值给指定的属性这样就得出了一个实体类对象再将这个对象赋值给property中的对象名--association propertydept javaTypeDeptid propertydid columndid/idresult propertydeptName columndept_name/result/association/resultMapselect idgetAllEmpAndDept resultMaptitle1select * from t_emp left join t_dept on t_emp.did t_dept .did where t_emp.eid #{eid}/selectResultTest /*** description:获取指定员工的信息(包括部门)* author: Hey* date: 2022/7/4 8:56* param: []* return: void**/Testpublic void getAllEmpAndDept(){SqlSession sqlSession SqlSessionUtils.getSqlSession();EmpMapper mapper sqlSession.getMapper(EmpMapper.class);Emp emp mapper.getAllEmpAndDept(3);System.out.println(emp);//Emp{eid3, empName懒洋洋, age34, sex男, email123qq.com}}3、方案三分步查询 mybatis-config.xml !--设置MyBatis的全局配置--settings!--将_自动映射为驼峰emp_name:empName--setting namemapUnderscoreToCamelCase valuetrue/!--开启延迟加载--setting namelazyLoadingEnabled valuetrue//settingsEmpMapper /*** description:通过分步查询查询员工以及员工所对应的部门信息* 分步查询第一步查询员工信息* author: Hey * date: 2022/7/4 9:41* param: [eid]* return: com.ir.mybatis.pojo.Emp**/Emp getEmpAndDeptByStepOne(Param(eid) Integer eid);EmpMapper.xml resultMap idempAndDeptByStepResultMap typeEmpid propertyeid columneid/idresult propertyempName columnemp_name/resultresult propertyage columnage/resultresult propertysex columnsex/resultresult propertyemail columnemail/result!--select:设置分步查询的sql的唯一标识namespace.SQLId或mapper接口的全类名.方法名column:设置分布查询的条件:根据员工的部门的did去查询该员工所属部门的信息fetchType:当开启了全局的延迟加载之后可通过此属性手动控制延迟加载的效果fetchTypelazy|eager:lazy表示延迟加载eager表示立即加载--association propertydeptselectcom.ir.mybatis.mapper.DeptMapper.getEmpAndDeptByStepTwocolumndid/association /resultMap!--Emp getEmpAndDeptByStepOne(Param(eid) Integer eid);--select idgetEmpAndDeptByStepOne resultMapempAndDeptByStepResultMapselect * from t_emp where eid #{eid}/selectDeptMapper /*** description:通过分步查询查询部门以及部门中所有的员工信息* 分步查询第二步根据did查询员工信息* author: Hey * date: 2022/7/4 9:42* param: [did]* return: java.util.Listcom.ir.mybatis.pojo.Emp**/ListEmp getDeptAndEmpByStepTwo(Param(did) Integer did);DeptMapper.xml !--Dept getEmpAndDeptByStepTwo(Param(did) Integer did);--select idgetEmpAndDeptByStepTwo resultTypeDeptselect * from t_dept where did #{did}/select ResultTest /*** description:通过分步查询查询部门以及部门中所有的员工信息* author: Hey * date: 2022/7/4 9:53* param: []* return: void**/Testpublic void testGetEmpAndDeptByStep(){SqlSession sqlSession SqlSessionUtils.getSqlSession();EmpMapper mapper sqlSession.getMapper(EmpMapper.class);Emp emp mapper.getEmpAndDeptByStepOne(3);System.out.println(emp);//Emp{eid3, empName懒洋洋, age34, sex男, email123qq.com}}
http://www.zqtcl.cn/news/697445/

相关文章:

  • 如何创建一个论坛网站免费域名解析平台
  • 国外经典手机网站设计单位做网站有哪些
  • 网站备案 优帮云百度提交入口网址截图
  • 广州五羊建设官方网站富阳区住房和城乡建设局网站
  • 网站代理怎么做的wordpress有什么缺点
  • 哪些网站可以做免费外贸Wordpress首图自动切换
  • 建网站几个按钮公司黄页企业名录在哪里查
  • 网站建设类外文翻译游戏开科技软件免费
  • 黄山家居网站建设怎么样济南在线制作网站
  • 东莞电子产品网站建设营销型网站推广方式的论文
  • 如何寻找做网站的客户聚名网查询
  • 甘肃制作网站凡科快图官网登录入口在线
  • discuz网站建设教学视频教程哪些大型网站有做互联网金融
  • jquery动画特效网站物流网站前端模板下载
  • 上海集团网站建设网站都是用什么语言写的
  • 地铁公司招聘信息网站网站推广页面 英语
  • 廊坊做网站的企业哪家好做网站app价格多少钱
  • wap网站制作当阳网站建设电话
  • 服装电子商务网站建设3000字中装建设有限公司
  • 河南卓越建设工程有限公司网站怎么做垂直门户网站
  • 接单做网页的网站手机端app开发公司
  • 古田路9号设计网站在线制作图片拼图
  • 深圳网站开发ucreator售后服务 网站建设
  • 做网站的语北京比较好的it公司
  • 长春建站模板制作php项目开发案例源码
  • 绍兴seo外包公司山东网站建设优化
  • php做网站知乎境外网站icp备案
  • 做seo网站图片怎么优化地坪漆东莞网站建设技术支持
  • wordpress theme forest济南优化网站排名
  • 简述网站的制作步骤合肥网站建设需