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

网站推广计划书具体包含哪些基本内容?wordpress导出html

网站推广计划书具体包含哪些基本内容?,wordpress导出html,专门型网站,wordpress时间文件夹1.1 resultType resultType: 执行 sql 得到 ResultSet 转换的类型#xff0c;使用类型的完全限定名或别名。 注意#xff1a;如果返回的是集合#xff0c;那应该设置为集合包含的类型#xff0c;而不是集合本身。resultType 和 resultMap#xff0c;不能同时使用。 A、…1.1 resultType resultType: 执行 sql 得到 ResultSet 转换的类型使用类型的完全限定名或别名。 注意如果返回的是集合那应该设置为集合包含的类型而不是集合本身。resultType 和 resultMap不能同时使用。 A、简单类型 接口方法 int countStudent();mapper 文件 !--resultType简单类型--select idcountStudent resultTypeintselect count(*) from student/select或者 !--resultType简单类型--select idcountStudent resultTypejava.lang.Integerselect count(*) from student/select注意resultType结果类型的它的值 类型的全限定名称类型的别名 例如 java.lang.Integer别名是int 测试文件 Testpublic void testReturnInt(){SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class); // 这句代码可以自动创建dao接口的实现类对象int count dao.countStudent();System.out.println(学生总人数 count);}B、 对象类型 接口方法 public Student selectStudentById(Param(studentId) Integer id);mapper 文件 select idselectStudentById resultTypecom.zep.domain.Studentselect id,name,email,age from student where id#{studentId} /select测试文件 Testpublic void testSelectStudentById() {/*** 使用mybatis的动态代理机制使用SqlSession.getMapper(dao接口)* getMapper能够获取dao接口对应的实现类对象。*/SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class); // 这句代码可以自动创建dao接口的实现类对象//调用dao的方法执行数据库的操作Student student dao.selectStudentById(1001);System.out.println(学生 student);}注意Dao 接口方法返回是集合类型需要指定集合中的类型不是集合本身。 mybatis中也可以对我们自定义的类型起别名 方法 1在mybatis主配置文件中定义使typeAlias定义别名 !--定义别名--typeAliases!--可以指定一个类型一个自定义别名type:自定义类型的全限定名称alis:别名短小容易记忆--typeAlias typecom.zep.domain.Student aliasstu/typeAlias typecom.zep.vo.ViewStudent aliasvstu//typeAliases2可以在resultType中使用自定义别名 接口方法 public Student selectStudentById(Param(studentId) Integer id);mapper 文件 select idselectStudentById resultTypestuselect id,name,email,age from student where id#{studentId} /select测试文件 Testpublic void testSelectStudentById() {/*** 使用mybatis的动态代理机制使用SqlSession.getMapper(dao接口)* getMapper能够获取dao接口对应的实现类对象。*/SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class); // 这句代码可以自动创建dao接口的实现类对象//调用dao的方法执行数据库的操作Student student dao.selectStudentById(1001);System.out.println(学生 student);}或者采用包扫描package: 1在mybatis主配置文件中定义使package定义别名 typeAliases!--第一种方式可以指定一个类型一个自定义别名type:自定义类型的全限定名称alis:别名短小容易记忆--!--typeAlias typecom.zep.domain.Student aliasstu/typeAlias typecom.zep.vo.ViewStudent aliasvstu/--!--第二种方式package name是包名这个包中的所有类类名就是别名类名不区分大小写--package namecom.zep.domain/package namecom.zep.vo//typeAliases2可以在resultType的值中可以省略前面在package标签name属性中已经写过的内容,只需要写类名即可,类名就是别名。 mapper文件 select idselectStudentById resultTypeStudentselect id,name,email,age from student where id#{studentId} /select测试文件 Testpublic void testSelectStudentById() {/*** 使用mybatis的动态代理机制使用SqlSession.getMapper(dao接口)* getMapper能够获取dao接口对应的实现类对象。*/SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class); // 这句代码可以自动创建dao接口的实现类对象//调用dao的方法执行数据库的操作Student student dao.selectStudentById(1001);System.out.println(学生 student);}C、 Map sql 的查询结果作为 Map 的 key 和 value。推荐使用 MapObject,Object。 注意Map 作为接口返回值sql 语句的查询结果最多只能有一条记录。大于一条记录是错误。 接口方法 //定义方法返回MapMapObject,Object selectMapById(Integer id);mapper 文件 !--返回Map1)列名是map的key,列值是map的value2)只能最多返回一行记录。多于一行会报错--select idselectMapById resultTypemapselect id,name from student where id#{stuid}/select或者 select idselectMapById resultTypejava.util.HashMapselect id,name from student where id#{stuid} /select测试文件 // 返回MapTestpublic void testSelectMap() {SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class); // 这句代码可以自动创建dao接口的实现类对象//调用dao的方法执行数据库的操作MapObject, Object map dao.selectMapById(1001);System.out.println(m map);}1.2 resultMap resultMap 可以自定义 sql 的结果和 java 对象属性的映射关系。更灵活的把列值赋值给指定属性。 常用在列名和 java 对象属性名不一样的情况。 使用方式 先定义 resultMap,指定列名和属性的对应关系。在select中把 resultType 替换为 resultMap。 注意 resultMap和resultType不要一起用二选一 接口方法 /*** 使用resultMap定义映射关系*/ListStudent selectAllStudents();mapper文件 !--使用resultMap1)先定义resultMap2)在select标签中使用resultMap来引用1中定义的。--!--定义resultMapid:自定义名称表示你定义的这个resultMaptype:java类型的全限定名称--resultMap idstudentMap typecom.zep.domain.Student!--定义列名和java属性的关系--!--主键列使用id标签column:列名property:java类型的属性名--id columnid propertyid/!--非主键列使用result标签--result columnname propertyname /result columnemail propertyemail /result columnage propertyage //resultMapselect idselectAllStudents resultMapstudentMapselect id,name,email,age from student/select测试文件 /**/Testpublic void testSelectAllStudents() {SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class);ListStudent students dao.selectAllStudents();for (Student student : students) {System.out.println(学生 student);}sqlSession.close();}列名和属性名不同的第一种解决方案 在domain文件夹下新建MyStudent.java package com.zep.domain;public class MyStudent {private Integer stuid;private String stuname;private String stuemail;private Integer stuage;Overridepublic String toString() {return MyStudent{ stuid stuid , stuname stuname \ , stuemail stuemail \ , stuage stuage };}public Integer getStuid() {return stuid;}public void setStuid(Integer stuid) {this.stuid stuid;}public String getStuname() {return stuname;}public void setStuname(String stuname) {this.stuname stuname;}public String getStuemail() {return stuemail;}public void setStuemail(String stuemail) {this.stuemail stuemail;}public Integer getStuage() {return stuage;}public void setStuage(Integer stuage) {this.stuage stuage;} } 接口方法 ListMyStudent selectMyStudent();mapper文件 resultMap idmyStudentMap typecom.zep.domain.MyStudentid columnid propertystuid/!--非主键列使用result标签--result columnname propertystuname /result columnemail propertystuemail /result columnage propertystuage //resultMap!--列名和属性名不一样--select idselectMyStudent resultMapmyStudentMapselect id,name,email,age from student/select测试文件 /**/Testpublic void testSelectMyStudent() {SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class);ListMyStudent students dao.selectMyStudent();for (MyStudent student : students) {System.out.println(学生 student);}sqlSession.close();}列名和属性名不同的第二种解决方案 采用列别名的方式给数据库的列名起一个别名让这个别名和属性名相同即可 接口方法 ListMyStudent selectDiffColProperty();mapper文件 !--列名和属性名不一样:第二种方式resultType的默认原则是 同名的列的值赋值给同名的属性所以使用列别名(java对象的属性名)即可解决--select idselectDiffColProperty resultTypecom.zep.domain.MyStudentselect id as stuid,name as stuname,email as stuemail ,age as stuage from student/select测试文件 Testpublic void testSelectDiffColProperty() {SqlSession sqlSession MybatisUtils.getSqlSession();StudentDao dao sqlSession.getMapper(StudentDao.class);ListMyStudent students dao.selectDiffColProperty();for (MyStudent student : students) {System.out.println(###学生 student);}sqlSession.close();}
http://www.pierceye.com/news/804906/

相关文章:

  • 深圳成品网站超市佛山网站建设机构
  • 江苏 网站建设第一次做网站做后感
  • wordpress翻译公司网站没事网站建设项目规划书
  • 东莞建设年审网站我的世界充钱网站怎么做
  • 太原网站排名系统电子商务市场营销
  • 社区网站开发进度表2018年做网站还能
  • 论企业网站建设的必要性内网网站搭建设
  • 网站建设怎么翻译如何建立自己的网站
  • 2345网址大全热门seo推广排名稳定
  • 网站建设工作有底薪吗360优化大师
  • 门户网站微信服务号建设大型网站建设优化排名
  • 贵州省冶金建设有限公司网站wordpress end_lvl
  • 网站建设的工作职责是什么网站后台显示连接已重置
  • 俱乐部手机网站模板微信公众号个人可以做网站么
  • 简述一个网站开发流程软件下载网站搭建
  • 超级营销型网站模板建湖人才网官网登录
  • 建设网站都需要什么万网二手已备案域名
  • 网站建设运营维护合同快捷建站专家
  • 中山建设网站公司软件工程开发
  • 网站备案logo韩国展厅设计网站
  • 网站建设沧州做网站导航能赚钱吗
  • 自己怎么创建免费网站wordpress使用插件
  • 做一个个人主页的网站怎么做商城小程序模板
  • 网站站内链接怎么做wordpress文章样式插件
  • 网站大全浏览器济南免费网站建设优化
  • 招聘网站入职分析表怎么做网站关键字挖掘
  • 锡盟本地网站建设网站欢迎页面代码
  • 有做网站吗个人站长网站
  • 免费网站模板下载图怪兽在线制作
  • 黑龙江网站设计公司广告海外推广