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

北京网站开发哪家专业如何写app程序

北京网站开发哪家专业,如何写app程序,推推蛙seo,室内设计图片自定义映射resultMap 自定义映射resultMap 自定义映射resultMapresultMap处理字段和属性的映射关系字段名和属性名不一致的情况#xff0c;如何处理映射关系?1、为查询的字段设置别名#xff0c;和属性名保持一致2、核心配置文件(mybatis-config.xml)中设置一个全局配置3、使…自定义映射resultMap 自定义映射resultMap 自定义映射resultMapresultMap处理字段和属性的映射关系字段名和属性名不一致的情况如何处理映射关系?1、为查询的字段设置别名和属性名保持一致2、核心配置文件(mybatis-config.xml)中设置一个全局配置3、使用resultMap自定义映射处理1处理多对一的映射关系①级联方式处理②association③分步查询 2处理一对多的映射关系 resultMap处理字段和属性的映射关系 字段名和属性名不一致的情况如何处理映射关系? 属性名 字段名 1、为查询的字段设置别名和属性名保持一致 select idgetEmpByEmpId resultTypeEmpselect emp_id empId,emp_name empName,age,gender from t_emp where emp_id #{empId}/select2、核心配置文件(mybatis-config.xml)中设置一个全局配置 当字段符合MySQL的要求使用_而属性符合java的要求使用驼峰 此时可以在MyBatis的核心配置文件(mybatis-config.xml)中设置一个全局配置可以自动将下划线映射为驼峰 emp_id:empId,emp_name:empName settings!--将下划线映射为驼峰--setting namemapUnderscoreToCamelCase valuetrue/!--开启延迟加载--setting namelazyLoadingEnabled valuetrue/!--按需加载--setting nameaggressiveLazyLoading valuefalse//settings3、使用resultMap自定义映射处理 resultMap设置自定义映射 属性 id表示自定义映射的唯一标识 type查询的数据要映射的实体类的类型 子标签 id设置主键的映射关系 result设置普通字段的映射关系 association设置多对一的映射关系 collection设置一对多的映射关系 属性 property设置映射关系中实体类中的属性名 column设置映射关系中表中的字段名 resultMap iduserMap typeUser id propertyid columnid/id result propertyuserName columnuser_name/result result propertypassword columnpassword/result result propertyage columnage/result result propertysex columnsex/result /resultMap !--ListUser testMohu(Param(mohu) String mohu);-- select idtestMohu resultMapuserMap !--select * from t_user where username like %${mohu}%-- select id,user_name,password,age,sex from t_user where user_name like concat(%,#{mohu},%) /select1处理多对一的映射关系 多个员工对应一个部门 ①级联方式处理 !-- 级联方式处理--resultMap idempAndDeptResultMapOne typeEmpid columnemp_id propertyempId/idresult columnemp_name propertyempName/resultresult columnage propertyage/resultresult columngender propertygender/resultresult columndept_id propertydept.deptId/resultresult columndept_name propertydept.deptName/result/resultMapselect idgetEmpAndDeptByEmpId resultMapempAndDeptResultMapOneselectt_emp.*,t_dept.*from t_empleft join t_depton t_emp.dept_id t_dept.dept_idwhere t_emp.emp_id #{empId}/select ②association !--association--resultMap idempAndDeptResultMap typeEmpid columnemp_id propertyempId/idresult columnemp_name propertyempName/resultresult columnage propertyage/resultresult columngender propertygender/result!--association处理多对一的映射关系处理实体类类型的属性property设置需要处理映射关系的属性的属性名javaType设置要处理的属性的类型--association propertydept javaTypeDeptid columndept_id propertydeptId/idresult columndept_name propertydeptName/result/association/resultMapselect idgetEmpAndDeptByEmpId resultMapempAndDeptResultMapselectt_emp.*,t_dept.*from t_empleft join t_depton t_emp.dept_id t_dept.dept_idwhere t_emp.emp_id #{empId}/select ③分步查询 DeptMapper.xml部门 select idgetEmpAndDeptByStepTwo resultTypeDeptselect * from t_dept where dept_id #{deptId}/select EmpMapper.xml员工 !--分步查询--resultMap idempAndDeptByStepResultMap typeEmpid columnemp_id propertyempId/idresult columnemp_name propertyempName/resultresult columnage propertyage/resultresult columngender propertygender/result!--property设置需要处理映射关系的属性的属性名select设置分步查询的sql的唯一标识column将查询出的某个字段作为分步查询的sql的条件fetchType在开启了延迟加载的环境中通过该属性设置当前的分步查询是否使用延迟加载fetchTypeeager(立即加载)|lazy(延迟加载)--association propertydept fetchTypeeagerselectcom.atguigu.mybatis.mapper.DeptMapper.getEmpAndDeptByStepTwocolumndept_id/association/resultMapselect idgetEmpAndDeptByStepOne resultMapempAndDeptByStepResultMapselect * from t_emp where emp_id #{empId}/select 2处理一对多的映射关系 一个部门对应多个员工 ①collection resultMap iddeptAndEmpResultMap typeDeptid columndept_id propertydeptId/idresult columndept_name propertydeptName/result!--ofType设置集合类型的属性中存储的数据的类型--collection propertyemps ofTypeEmpid columnemp_id propertyempId/idresult columnemp_name propertyempName/resultresult columnage propertyage/resultresult columngender propertygender/result/collection/resultMapselect idgetDeptAndEmpByDeptId resultMapdeptAndEmpResultMapSELECT *FROM t_deptLEFT JOIN t_empON t_dept.dept_id t_emp.dept_idWHERE t_dept.dept_id #{deptId}/select ②分步查询 DeptMapper.xml部门 resultMap iddeptAndEmpResultMapByStep typeDeptid columndept_id propertydeptId/idresult columndept_name propertydeptName/resultcollection propertyempsselectcom.atguigu.mybatis.mapper.EmpMapper.getDeptAndEmpByStepTwocolumndept_id/collection/resultMap!--Dept getDeptAndEmpByStepOne(Param(deptId) Integer deptId);--select idgetDeptAndEmpByStepOne resultMapdeptAndEmpResultMapByStepselect * from t_dept where dept_id #{deptId}/selectEmpMapper.xml员工 select idgetDeptAndEmpByStepTwo resultTypeEmpselect * from t_emp where dept_id #{deptId}/select
http://www.hkea.cn/news/14347690/

相关文章:

  • 建站如何挣钱国外网站大全帝国cms模板
  • 网站的版式设计长春站是火车站还是高铁站
  • 临安做企业网站的公司网站建设与实践模板
  • 汕头网站建设备案乐陵seo营销
  • 公司模块网站制作中国建设银行行号查询
  • 零食网站建设的策划书景区协会官方网站建设
  • 找个专门做各种外卖的网站昆山规划建设局网站
  • 有关网站开发的国外书籍app开发公司应聘
  • 工程建设指挥部网站携程网站模板
  • 如何做新增网站备案wordpress 加入视频
  • 微信公众号做留言网站淘宝做网站被骗
  • c4d培训机构推荐网络优化seo是什么工作
  • 顺德互动交流网站wordpress模板+保险
  • 第一章 网站建设基本概述凡科建站代理登录
  • 广州手机网站建设报价表哪个大学的网站做的最好看
  • 旅游网站管理系统做网站公司 信科网络
  • 深圳做网站价比高的公司性做网站的前端技术
  • 网站关键词排名优化软件集团网站策划方案
  • 找工程分包网站杭州百度人工优化
  • 建设游戏运营网站开展工作总结福州精美个人网站建设公司
  • 饿了么企业网站上海做网址域名的公司
  • 网站点赞怎么做的做网站要什么软件
  • 那个网站的公众后推广做的好app开发公司官网
  • 长沙建立企业网站最好的网站建设公司
  • 电子商务网站建设与维护概述家庭室内装修设计公司
  • 最好加盟网站建设厦门北京网站建设
  • asp个人网站下载做网站基础源代码
  • 北京康迪建设监理咨询有限公司网站网易企业邮箱申请
  • 技术支持东莞网站建设机械网易企业邮箱过期了
  • 滁州网站建设工作室网易企业邮箱手机登录