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

网站被降权重新做网站昭阳区住房和城乡建设管理局网站

网站被降权重新做网站,昭阳区住房和城乡建设管理局网站,最近刚发生的新闻,在线做ppt的网站源代码Mybatis返回值接收 可以使用两种方式进行参数的接收 resultTyperesultMap 这两种分别都是需要在Mapper.xml文件中去设置的 当结果是一个简单的对象或者list或者map#xff0c;对象中没有嵌套对象#xff0c;或者集合时#xff0c;就可以直接使用resultType 反之如果需要…Mybatis返回值接收 可以使用两种方式进行参数的接收 resultTyperesultMap 这两种分别都是需要在Mapper.xml文件中去设置的 当结果是一个简单的对象或者list或者map对象中没有嵌套对象或者集合时就可以直接使用resultType 反之如果需要返回的值是一个复杂对象其中包含list或者map的时候就需要使用resultMap去确定返回值格式 1 使用 resultType sql idbasicSelectid,name,age,address,emp_detail /sql查询单个Map对象 select idselectUsers resultTypemapselect id, username, hashedPasswordfrom some_tablewhere id #{id} /selectMap selectUsers(Long id);查询具体单个对象 select idselectEmpById resultTypecn.sycoder.domain.Employeeselectinclude refidbasicSelect/includefrom employee where id #{id}/select !-- 定义sql-- sql idbasicSelectid,name,age,address,emp_detail /sqlEmployee selectEmpById(Long id);查询集合对象 select idselectEmp resultTypecn.sycoder.domain.Employeeselectinclude refidbasicSelect/includefrom employeewhere id #{id} /selectListEmployee selectEmp(Long id);查询单个值 select idselectCount resultTypejava.lang.Integerselect count(*) from employee /selectInteger selectCount();2 使用 resultMap 2.1 简单使用 应用场景实体类属性和数据库列名不匹配的时候比如数据库采用经典命名法java 使用驼峰命名法的时候 resultMap idbasicMap typecn.sycoder.domain.Employee !-- 设置数据库id 的对应字段--id propertyid columnid/idresult propertyempDetail columnemp_detail/resultresult propertyname columnname/result/resultMapselect idselectEmpById resultMapbasicMapselectinclude refidbasicSelect/includefrom employee where id #{id}/select解决方式2 settingssetting namemapUnderscoreToCamelCase valuetrue//settingsid result id propertyid columnpost_id/ result propertysubject columnpost_subject/id result 属性 属性描述property映射到列结果的字段或属性。如果 JavaBean 有这个名字的属性property会先使用该属性。否则 MyBatis 将会寻找给定名称的字段field。无论是哪一种情形你都可以使用常见的点式分隔形式进行复杂属性导航。 比如你可以这样映射一些简单的东西“username”或者映射到一些复杂的东西上“address.street.number”。 stu.namecolumn数据库中的列名或者是列的别名。一般情况下这和传递给 resultSet.getString(columnName) 方法的参数一样。javaType一个 Java 类的全限定名或一个类型别名关于内置的类型别名可以参考上面的表格。 如果你映射到一个 JavaBeanMyBatis 通常可以推断类型。然而如果你映射到的是 HashMap那么你应该明确地指定 javaType 来保证行为与期望的相一致。 2.2多结果集处理前期准备 新建学生和班级表 create table class (id bigint auto_incrementprimary key,name varchar(64) null );create table student (id bigint auto_incrementprimary key,name varchar(64) null,age int null,class_id bigint null,constraint student_class_id_fkforeign key (class_id) references class (id) );insert into class values (null,软工1班),(null,计科2班);insert into student (id, name, age,class_id) values (null,sy,18,1),(null,zs,19,1),(null,zz,20,1),(null,小明,22,2); 2.3一对多处理 collection 使用 collection 就可以获取到多个结果集对象 一个班级对应多个学生 操作 第一步新建 mapper 方法 public interface ClassMapper {MyClass getById(Long id); }第二步编写 xml resultMap idbasicMap typecn.sycoder.domain.MyClassid propertyid columnid/idresult propertyname columnname/result !-- 获取学生信息信息--collection propertystus ofTypecn.sycoder.domain.Studentid propertyid columnsId/idresult propertyname columnsName/resultresult propertyage columnage/resultresult propertyclassId columnclass_id/result/collection/resultMapselect idgetById resultMapbasicMapselectc.*,s.id sId,s.name sName,s.age,s.class_idfromclass c left join student s on c.id s.class_idwhere c.id #{id}/select2.4多对一的处理 关联association如果我的类里面有其它对象的关联关系可以使用 association 来进行操作 属性描述property映射到列结果的字段或属性。如果用来匹配的 JavaBean存在给定名字的属性那么它将会被使用。否则 MyBatis 将会寻找给定名称的字段。无论是哪一种情形你都可以使用通常的点式分隔形式进行复杂属性导航。比如你可以这样映射一些简单的东西“username”或者映射到一些复杂的东西上“address.street.number”。javaType一个 Java 类的完全限定名或一个类型别名关于内置的类型别名可以参考上面的表格。 如果你映射到一个 JavaBeanMyBatis 通常可以推断类型。然而如果你映射到的是HashMap那么你应该明确地指定 javaType 来保证行为与期望的相一致。 传统操作 使用级联操作 resultMap idbasicMap typecn.sycoder.domain.Studentid propertyid columnid/idresult propertyname columnname/resultresult propertyage columnage/resultresult propertyclassId columnclass_id/resultresult propertycls.id columncId/resultresult propertycls.name columncName/result/resultMapselect idlistAllStus resultMapbasicMapselectstu.*,c.id cId,c.name cNamefromstudent stu left join class c on stu.class_id c.id/select使用 association 操作 代码 resultMap idAssociationMap typecn.sycoder.domain.Studentid propertyid columnid/idresult propertyname columnname/resultresult propertyage columnage/resultresult propertyclassId columnclass_id/resultassociation propertycls javaTypecn.sycoder.domain.MyClassid propertyid columncId/idresult propertyname columncName/result/association/resultMapselect idlistAllStusByAssociation resultMapAssociationMapselectstu.*,c.id cId,c.name cNamefromstudent stu left join class c on stu.class_id c.id/select3 嵌套 select 查询 以多条sql 的方式执行 3.1关联关系 assciation select 查询学生信息包含班级信息 resultMap idAssociationSelectMap typecn.sycoder.domain.Studentid propertyid columnid/idresult propertyname columnname/resultresult propertyage columnage/resultresult propertyclassId columnclass_id/resultassociation propertycls columnclass_idselectcn.sycoder.mapper.StudentMapper.getClassById//resultMapselect idlistAllStusByAssociationSelect resultMapAssociationSelectMapselect * from student/selectselect idgetClassById resultTypecn.sycoder.domain.MyClassselect * from class where id #{id}/select如果关联的是多个结果集使用 resultSet 属性描述column当使用多个结果集时该属性指定结果集中用于与 foreignColumn 匹配的列多个列名以逗号隔开以识别关系中的父类型与子类型。foreignColumn指定外键对应的列名指定的列将与父类型中 column 的给出的列进行匹配。resultSet指定用于加载复杂类型的结果集名字。resultMap idblogResult typeBlogid propertyid columnid /result propertytitle columntitle/association propertyauthor javaTypeAuthor resultSetauthors columnauthor_id foreignColumnidid propertyid columnid/result propertyusername columnusername/result propertypassword columnpassword/result propertyemail columnemail/result propertybio columnbio//association /resultMap3.2 collection select 需求通过班级去查学生使用嵌套 select 查询 resultMap idcollectionSelect typecn.sycoder.domain.MyClassid propertyid columnid/idresult propertyname columnname/result!-- 获取学生信息信息--collection propertystus ofTypecn.sycoder.domain.StudentselectgetStudentByClassId columnid//resultMapselect idgetByClassId resultMapcollectionSelectselect * from class where id #{id}/selectselect idgetStudentByClassId resultTypecn.sycoder.domain.Studentselect * from student where class_id #{id}/select3.3 关联查询的总结 优点 可以实现延迟加载前提是要配置sql 写起来变得简单了 缺点 发起了多条 sql,正常查询只发起一条sql
http://www.hkea.cn/news/14443087/

相关文章:

  • 广州建设手机网站网站建设模板怎么直接套
  • 公司网站建设为什么不直接买模版wordpress能生成静态文件下载
  • 自己设计logo网站网站用社交图标做链接侵权吗
  • 宁夏商擎网站建设公司静态网站模板
  • 建设商城网站公司百度百科百度网站主要提供的服务
  • 做招聘网站的怎么让人注册简历上海关键词优化公司哪家好
  • 网站域名到期叫拍卖网站建设需求
  • 家乡ppt模板免费下载网站wordpress固定链接index.php
  • wordpress网站制作app中国贸易网官网手机版
  • 电脑淘宝网页版怎么优化网站打开速度
  • 洋县建设银行网站域名网
  • 南充 网站建设怎样自己创建一个网站
  • 仿v电影wordpress保定seo网络推广
  • 如何看一个网站做的如何万网 安装wordpress
  • go语言做的网站江西智能网站建设
  • 企业网站改一下多少钱ftp网站 免费
  • 常州武进网站建设阿里云域名拍卖
  • 建设银行的网站用户名学生怎么制作网站
  • 广丰做网站公司同城信息小程序源码
  • 微信微网站开发价格广州品牌策划公司
  • 上海互联网网站建设公司淘宝网网页版登录入口在哪里
  • 找建筑网站哪里网站书最全
  • 用cms做网站怎么样形容网站做的好
  • 免费1级做爰片免费网站网络运维app
  • 辽宁营销型网站建设济南腾飞网络科技有限公司
  • 有哪些装修网站沃噻网站建设流程
  • o2o商城网站搭建制作网线的步骤
  • 西宁那有做网站的seo收费
  • 宁波易企网做的网站河南高端网站
  • 媒体网站 建设网络强国海外推广