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

php网站开发答案怎样免费建个人网站

php网站开发答案,怎样免费建个人网站,郴州在湖南什么位置,广告标识标牌制作公司与association一样#xff0c;collection元素也有两种形式#xff0c;现介绍如下#xff1a; 一、嵌套的resultMap 实际上以前的示例使用的就是这种方法#xff0c;今天介绍它的另一种写法。还是以教师映射为例#xff0c;修改映射文件TeacherMapper.xml如下#xff08;点… 与association一样collection元素也有两种形式现介绍如下 一、嵌套的resultMap       实际上以前的示例使用的就是这种方法今天介绍它的另一种写法。还是以教师映射为例修改映射文件TeacherMapper.xml如下点击此处进入嵌套resultMap形式的示例源码下载页面。注本示例代码是在修改本系列的上篇博文示例代码的基础上完成的用到了MapperScannerConfigurer和注解等知识。对这些知识不熟悉的读者可参考上篇博文http://legend2011.blog.51cto.com/3018495/980150 ?xml version1.0 encodingutf8? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd !--与以前一样namespace的值是对应的映射器接口的完整名称-- mapper namespacecom.abc.mapper.TeacherMapper !--TeacherMapper接口中getById方法对应的SQL语句。 查询教师及其指导的学生的信息。由于教师、学生都有 id、name、gender等属性因此给教师的字段都起了别名-- select idgetById parameterTypeint resultMapsupervisorResultMap select t.id t_id, t.name t_name, t.gender t_gender, t.research_area t_research_area, t.title t_title, s.id,s.name, s.gender,s.major,s.grade from teacher t,student s where t.id#{id} and s.supervisor_id t.id /select !--教师实体映射-- resultMap idsupervisorResultMap typeTeacher id propertyid columnt_id/ result propertyname columnt_name/ result propertygender columnt_gender/ result propertyresearchArea columnt_research_area/ result propertytitle columnt_title/ !--需要注意的是上面的select语句中学生的字段名/别名应与 下面的column属性一致。ofType指collection包含的元素的类型 此属性不可少-- collection propertysupStudentsofTypeStudent id propertyid columnid/ result propertyname columnname/ result propertygender columngender/ result propertymajor columnmajor/ result propertygrade columngrade/ !--映射学生的指导教师属性用到了 supervisorResultMap本身-- association propertysupervisor resultMapsupervisorResultMap/ /collection /resultMap /mapper     运行程序结果如下         与以前的写法相比这种写法的缺点是学生实体映射被嵌入到教师实体映射中因此学生实体映射不能被重用。 二、嵌套的select语句       这种方式是使用一条单独的select语句来加载关联的实体在本例中就是学生实体然后在collection元素中引用此select语句注此方法会产生N1问题关于这个问题可参考本系列博客中的“MyBatis中的N1问题”。首先修改TeacherMapper.xml如下点击此处进入嵌套select语句形式示例源码下载页面 ?xml version1.0 encodingutf8? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd !--与以前一样namespace的值是对应的映射器接口的完整名称-- mapper namespacecom.abc.mapper.TeacherMapper !--TeacherMapper接口中getById方法对应的SQL语句。 查询教师的信息。-- select idgetById parameterTypeint resultMapsupervisorResultMap select * from teacher where id#{id} /select !--教师实体映射-- resultMap idsupervisorResultMap typeTeacher id propertyid columnid/ result propertyname columnname/ result propertygender columngender/ result propertyresearchArea columnresearch_area/ result propertytitle columntitle/ !--ofType指collection包含的元素的类型此属性不可少。 column属性指把上述的getById的select语句中的教师id列的值作为参数 传递给将要引用到的下述的getStudents的select语句此属性不可少。 引用的形式为命名空间.select语句id-- collection propertysupStudents columnid ofTypeStudent selectcom.abc.mapper.StudentMapper.getStudents/ /resultMap /mapper        在这里把根据指导教师id查询学生信息的SQL语句写在StudentMapper.xml中并引用其中的学生实体映射studentResultMap。修改StudentMapper.xml如下 ?xml version1.0 encodingutf8? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.abc.mapper.StudentMapper resultMap idstudentResultMap typeStudent id propertyid columnid/ result propertyname columnname/ result propertygender columngender/ result propertymajor columnmajor/ result propertygrade columngrade/ !--在这里引用supervisorResultMap和getById 亦采用命名空间名.相关元素id的形式。 columnsupervisor_id属性不可少-- association propertysupervisor resultMapcom.abc.mapper.TeacherMapper.supervisorResultMap selectcom.abc.mapper.TeacherMapper.getById columnsupervisor_id/ /resultMap !--根据指导教师id查询学生信息-- select idgetStudents parameterTypeint resultMapstudentResultMap select * from student where supervisor_id #{id} /select /mapper    执行结果如下       从以上可看出collection的这两种形式与association的两种形式非常相似。
http://www.pierceye.com/news/615886/

相关文章:

  • 重庆微信网站建设网站平台网站怎么做
  • 90设计网站几次是什么意思厦门建设工程信息网官网
  • 小说章节收费网站建设东莞网络营销网站建设
  • 找工作网站如何设计一款软件
  • 贵金属企业网站源码手机端网站加盟
  • 大连企业网站排名优化平面设计和网页设计
  • 广州网站建设工作室招聘文创产品设计分析
  • 产品是做网站seo网站设计费用
  • 公司网站的搭建方案做海报图片的网站
  • 纯文本网站建设小米发布会最新
  • 定制版网站建设费用网站服务器干啥
  • 漂亮的网站是什么建设出来的弄一个小程序要多少钱
  • 房地产网站模板 下载免费空间和域名
  • 通付盾 建设网站公司最新永久地域自动跳转
  • 宁波建网站选哪家好一点wordpress手机全部显示
  • 如何注册属于自己的网站做列表的网站
  • 网站公司seo杭州网站建设模板
  • 网站内链如何布局优化大师下载
  • 如何做网站需求表格清单电影购买网站怎么设计
  • 有口碑的常州网站建设家政公司网站建设方案
  • 用户体验设计师吉林网站seo
  • 便宜营销型网站建设优化建站多网站绑定域名
  • 什么网站教人做3d效果图网站建设电话销售不被挂断
  • 村级网站建设 不断增强免费logo设计图案创意
  • 做网站优化有什么途径什么类型的公司需要做建设网站的
  • 计算机毕设代做网站深圳自适应网站开发
  • 万网主机建设网站流程idc 网站备案
  • 收费用的网站怎么做珠海网站关键词推广
  • 学技巧网站制作网站建设税率多少
  • 高端网站设计平台网页设计模板的网站