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

传媒网站建设国内跨境电商平台有哪些?

传媒网站建设,国内跨境电商平台有哪些?,韩国最新新闻,网站建设和推广话术8.1、resultMap处理字段和属性的映射关系 若字段名和实体类中的属性名不一致#xff0c;则可以通过resultMap设置自定义映射 !--resultMap#xff1a;设置自定义映射属性#xff1a;id#xff1a;表示自定义映射的唯一标识type#xff1a;查询的数据要映射的实体类的…8.1、resultMap处理字段和属性的映射关系 若字段名和实体类中的属性名不一致则可以通过resultMap设置自定义映射 !--resultMap设置自定义映射属性id表示自定义映射的唯一标识type查询的数据要映射的实体类的类型子标签id设置主键的映射关系result设置普通字段的映射关系association设置多对一的映射关系collection设置一对多的映射关系属性property设置映射关系中实体类中的属性名column设置映射关系中表中的字段名 -- resultMap iduserMap typeUserid propertyid columnid/idresult propertyuserName columnuser_name/resultresult propertypassword columnpassword/resultresult propertyage columnage/resultresult 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},%) /select若字段名和实体类中的属性名不一致但是字段名符合数据库的规则使用_实体类中的属性名符合Java的规则使用驼峰 此时也可通过以下两种方式处理字段名和实体类中的属性的映射关系 可以通过为字段起别名的方式保证和实体类中的属性名保持一致可以在MyBatis的核心配置文件中设置一个全局配置信息mapUnderscoreToCamelCase可以在查询表中数据时自动将_类型的字段名转换为驼峰 settingssetting namemapUnderscoreToCamelCase valuetrue/ /settings例如字段名user_name设置了mapUnderscoreToCamelCase此时字段名就会转换为userName ListUser getAllUser();select idgetAllUser resultTypeUserselect * from t_user /select查询结果 [User(id4, userNameadmin, password123456, age18, gender男, email), User(id5, userNameadmin, password123456, age18, gender男, email)]8.2、多对一映射处理 场景模拟 查询员工信息以及员工所对应的部门信息 8.2.1、级联方式处理映射关系 resultMap idempDeptMap typeEmp id columneid propertyeid/idresult columnename propertyename/resultresult columnage propertyage/resultresult columnsex propertysex/resultresult columndid propertydept.did/resultresult columndname propertydept.dname/result /resultMap !--Emp getEmpAndDeptByEid(Param(eid) int eid);-- select idgetEmpAndDeptByEid resultMapempDeptMapselect emp.*,dept.* from t_emp emp left join t_dept dept on emp.did dept.did where emp.eid #{eid} /select8.2.2、使用association处理映射关系 resultMap idempDeptMap typeEmp id columneid propertyeid/idresult columnename propertyename/resultresult columnage propertyage/resultresult columnsex propertysex/resultassociation propertydept javaTypeDeptid columndid propertydid/idresult columndname propertydname/result/association /resultMap !--Emp getEmpAndDeptByEid(Param(eid) int eid);-- select idgetEmpAndDeptByEid resultMapempDeptMapselect emp.*,dept.* from t_emp emp left join t_dept dept on emp.did dept.did where emp.eid #{eid} /select8.2.3、分步查询 1、查询员工信息 /** * 通过分步查询查询员工信息 * param eid * return */ Emp getEmpByStep(Param(eid) int eid);resultMap idempDeptStepMap typeEmpid columneid propertyeid/idresult columnename propertyename/resultresult columnage propertyage/resultresult columnsex propertysex/result!--select设置分步查询查询某个属性的值的sql的标识namespace.sqlIdcolumn将sql以及查询结果中的某个字段设置为分步查询的条件--association propertydept selectcom.atguigu.MyBatis.mapper.DeptMapper.getEmpDeptByStep columndid/association /resultMap!--Emp getEmpByStep(Param(eid) int eid);-- select idgetEmpByStep resultMapempDeptStepMapselect * from t_emp where eid #{eid} /select2、根据员工所对应的部门id查询部门信息 /** * 分步查询的第二步 根据员工所对应的did查询部门信息 * param did * return */ Dept getEmpDeptByStep(Param(did) int did);!--Dept getEmpDeptByStep(Param(did) int did);-- select idgetEmpDeptByStep resultTypeDeptselect * from t_dept where did #{did} /select8.3、一对多映射处理 8.3.1、collection /** * 根据部门id查新部门以及部门中的员工信息 * param did * return */ Dept getDeptEmpByDid(Param(did) int did);resultMap iddeptEmpMap typeDeptid propertydid columndid/idresult propertydname columndname/result!--ofType设置collection标签所处理的集合属性中存储数据的类型--collection propertyemps ofTypeEmpid propertyeid columneid/idresult propertyename columnename/resultresult propertyage columnage/resultresult propertysex columnsex/result/collection /resultMap!--Dept getDeptEmpByDid(Param(did) int did);-- select idgetDeptEmpByDid resultMapdeptEmpMapselect dept.*,emp.* from t_dept dept left join t_emp emp on dept.did emp.did where dept.did #{did} /select8.3.2、分步查询 1、查询部门信息 /** * 分步查询部门和部门中的员工 * param did * return */ Dept getDeptByStep(Param(did) int did);resultMap iddeptEmpStep typeDeptid propertydid columndid/idresult propertydname columndname/resultcollection propertyemps fetchTypeeager selectcom.atguigu.MyBatis.mapper.EmpMapper.getEmpListByDid columndid/collection /resultMap!--Dept getDeptByStep(Param(did) int did);-- select idgetDeptByStep resultMapdeptEmpStepselect * from t_dept where did #{did} /select备注javaType和ofType都是用来指定对象类型的但是javaType是用来指定pojo中属性的类型而ofType指定的是映射到list集合属性中pojo的类型。 2、根据部门id查询部门中的所有员工 /** * 根据部门id查询员工信息 * param did * return */ ListEmp getEmpListByDid(Param(did) int did);!--ListEmp getEmpListByDid(Param(did) int did);-- select idgetEmpListByDid resultTypeEmpselect * from t_emp where did #{did} /select分步查询的优点可以实现延迟加载 但是必须在核心配置文件中设置全局配置信息 lazyLoadingEnabled延迟加载的全局开关。当开启时所有关联对象都会延迟加载 aggressiveLazyLoading当开启时任何方法的调用都会加载该对象的所有属性。否则每个属性会按需加载 也可以通过association和collection中的fetchType属性设置当前的分步查询是否使用延迟加载 fetchType“lazy(延迟加载)|eager(立即加载)” 更多关于延迟加载的资料可以参考https://www.cnblogs.com/zbh355376/p/14986307.html 本文章参考B站 【尚硅谷】SSM框架全套教程MyBatisSpringSpringMVCSSM整合一套通关仅供个人学习使用部分内容为本人自己见解与尚硅谷无关。
http://www.dnsts.com.cn/news/20080.html

相关文章:

  • 中文网站建设公司基于php的图书管理系统论文
  • 往网站上传照片怎么做h5网页版制作
  • 什么是网站模板长春网站建设长春
  • 做网站客源wordpress关键词内链插件
  • 专业网站构建苏州网站设计公司
  • 虚拟主机能建设网站吗网站后台登陆显示验证码错误
  • 网站域名备案查询什么网站可以做告白的网页
  • 如何建手机销售网站网站设计是什么
  • 河北邢台企业做网站沧州做网站最好的公司
  • 个人网站模板素材津南区网络推广公司
  • 刘淼 网站开发用户研究 网站
  • 常州城乡建设局网站首页东莞seo托管
  • 一站式装修平台怎么学会建自己网站的方法
  • 没有网站也可以做cpa恢复网址
  • 网站公司倒闭flash 网站头部
  • 湛江有没有做网站的公司建设网站多少钱
  • 快速生成网站程序公司建站网站
  • 大学网站开发模板免费下载拍摄视频制作的广告公司
  • 建站群赚钱有前途吗青岛建站推广
  • 无锡做网站公司多少钱石家庄专门做网站
  • 网页制作与网站建设宝典 pdf在网站做的pdf有水印如何删除
  • 做网站产品搜索展示实现提供手机网站建设哪家好
  • 中国建设投资集团 网站首页微信小程序怎么批量删掉
  • 网站安全检测怎么关掉惠州网站制作案例
  • 网站换空间的流程网站编辑做图片用什么不同
  • 网站开发文档是什么概念如何搭建免费网站
  • 企业网站推广建议html网站模板免费
  • 合肥快速做网站中企动力建设网站怎么样
  • seo点击器汕头最好的seo外包
  • 怎么查看网站访问速度大网站设计