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

青岛私人做网站wordpress收款

青岛私人做网站,wordpress收款,国内哪家网站做的系统纯净,已经有备案的公司网站 还能不能加网站核心配置 JavaBeanMapper.xml#xff08;sql映射#xff09; 作用 JavaBeanMapper.xml实现#xff1a; 用来干什么#xff1f; 定义Sql语句映射。相对照JDBC的实现#xff0c;是将原本的Sql代码提取出来#xff0c;最终根据映射关系执行Sql操作。 好处#xff1f; 解…核心配置 JavaBeanMapper.xmlsql映射 作用 JavaBeanMapper.xml实现 用来干什么 定义Sql语句映射。相对照JDBC的实现是将原本的Sql代码提取出来最终根据映射关系执行Sql操作。 好处 解耦mapper只关心定义Sql的映射关系与java代码分离更易维护。 如何使用 先来展示一个基本的mapper xml这里涉及到主要的几个标签元素 SelectInsertUpdateDeleteResultMapSqlCache ?xml version1.0 encodingUTF-8? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespaceorg.example.daos.UserMapperresultMap iduserMap typeCustomerresult columnpwd propertypassword//resultMapselect idgetUserList resultMapuserMapSELECT * FROM mybatis.user/selectselect idgetUserListByRowBounds resultMapuserMapSELECT * FROM mybatis.user/select!-- 模糊查询1--!--select idgetUserListForFuzzyQuery resultTypeorg.example.pojo.UserSELECT * FROM mybatis.user where name like #{name}/select--!-- 模糊查询2 %--select idgetUserListForFuzzyQuery resultTypeorg.example.pojo.UserSELECT * FROM mybatis.user where name like %#{name}/select!-- 形参只有一个且为基本类型时parameterType可省略parameterTypeint --select idgetUserById resultTypeorg.example.pojo.UserSELECT * FROM mybatis.user where id #{id}/selectinsert idaddUser parameterTypeorg.example.pojo.UserINSERT INTO mybatis.user(id, name, pwd) values (#{id},#{name},#{pwd})/insertupdate idupdateUserByUser parameterTypeorg.example.pojo.UserUPDATE mybatis.user set name#{name}, pwd#{pwd} where id#{id}/updateupdate idupdateUserByMap parameterTypemapUPDATE mybatis.user set name#{userName}, pwd#{userPwd} where id#{userId}/updatedelete iddeleteUser parameterTypeintDELETE FROM mybatis.user where id#{id}/delete /mapper 具体的标签元素 Select 这里的重点是resultTyperesultMap的使用两者只能二选一 ResultType语句中返回结果的类全限定名或别名。一般是该sql映射方法的返回值类型。特殊的如果是集合类型则只需定义集合的泛型类型即可。ResultMap对外部 resultMap 的命名引用。一般用于处理复杂的映射结果查询比如多表查询一对多多对一 多对一查询 ?xml version1.0 encodingUTF-8? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespaceorg.example.daos.StudentMapper!-- 多对一查询方式1Teacher再查一次:子查询相当于:select id, name, tid from student where tid (select id from teacher where id tid)--!--resultMap idStudentTeacher1 typeStudentid propertyid columnid/result columnname propertyname/association propertyteacher columntid selectgetTeacherById javaTypeTeacher//resultMapselect idgetStudentList resultMapStudentTeacher1select * from student/selectselect idgetTeacherById resultTypeTeacherselect * from teacher where id#{tid}/select--!-- 多对一查询方式2按照结果嵌套, 联表查询相当于select s.id sid, s.name sname, t.id tid, t.name tname from student s, teacher t where s.tid t.id--select idgetStudentList resultMapStudentTeacher2select s.id sid, s.name sname, t.id tid, t.name tname from student s, teacher t where s.tid t.id/selectresultMap idStudentTeacher2 typeStudentresult propertyid columnsid/result propertyname columnsname/association propertyteacher javaTypeTeacherid columnid propertytid/result propertyname columntname//association/resultMap/mapper一对多查询 ?xml version1.0 encodingUTF-8? !DOCTYPE mapper PUBLIC -//mybatis.org//DTD Mapper 3.0//EN http://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespaceorg.example.daos.TeacherMapper!--一对多方式1联表查询 --select idgetTeacherById resultMapTeacherStudentselect t.id tid, t.name tname, s.id sid, s.name sname from teacher t, student s where t.id s.tid and t.id#{tid}/selectresultMap idTeacherStudent typeTeacherresult propertyid columntid/result propertyname columntname/collection propertystudentList ofTypeStudentresult propertyid columnsid/result propertyname columnsname/result propertytid columntid//collection/resultMap!--一对多方式2子查询 --select idgetTeacherById2 resultMapTeacherStudent2select * from teacher where id#{tid}/selectresultMap idTeacherStudent2 typeTeacherresult columnid propertyid/collection propertystudentList columnid ofTypeStudent selectgetStudentByTid//resultMapselect idgetStudentByTid resultTypeStudentselect * from student where tid#{tid}/select /mapperInsert涉及到自动生成主键id的设置(keyProperty, useGeneratedKeys)多行插入(foreach)UpdateDelete !-- 自动生成主键id -- insert idinsertAuthor useGeneratedKeystruekeyPropertyidinsert into Author (username,password,email,bio)values (#{username},#{password},#{email},#{bio}) /insert!-- 多行插入 -- insert idinsertAuthor useGeneratedKeystruekeyPropertyidinsert into Author (username, password, email, bio) valuesforeach itemitem collectionlist separator,(#{item.username}, #{item.password}, #{item.email}, #{item.bio})/foreach /insertupdate idupdateAuthorupdate Author setusername #{username},password #{password},email #{email},bio #{bio}where id #{id} /updatedelete iddeleteAuthordelete from Author where id #{id} /deleteSqlsql语句重用片段。也可动态赋值 sql idif_title_authorif testtitle! nullAND title #{title}/ifif testauthor ! nullAND author #{author}/if /sqlselect idqueryBlog1 parameterTypemapselect * from blog where 11include refidif_title_author/ /select!-- 动态赋值: ${include_target}, property -- sql idsomeincludefrominclude refid${include_target}/ /sql select idselect resultTypemapselectfield1, field2, field3include refidsomeincludeproperty nameprefix valueSome//include /select参数的定义 如果一个列允许使用 null 值并且会使用值为 null 的参数就必须要指定 JDBC 类型jdbcType #{average,javaTypedouble,jdbcTypeNUMERIC,typeHandlerMyTypeHandler,numericScale2}字符串替换: ${}方式不会被预编译转义可以通过这种方式指定某个字符串column而非对应的数值。但存在sql注入风险。 Select(select * from user where ${column} #{value}) User findByColumn(Param(column) String column, Param(value) String value);association collection collection 用于一对多association用于多对一。 association 联表查询 association propertyauthor columnblog_author_id javaTypeAuthorid propertyid columnauthor_id/result propertyusername columnauthor_username/ /associationassociation 子表查询 resultMap idblogResult typeBlogassociation propertyauthor columnauthor_id javaTypeAuthor selectselectAuthor/ /resultMapcollection子表查询 collection propertyposts columnid ofTypePost selectselectPostsForBlog/collection联表查询 resultMap idblogResult typeBlogid propertyid columnblog_id /result propertytitle columnblog_title/collection propertyposts ofTypePostid propertyid columnpost_id/result propertysubject columnpost_subject/result propertybody columnpost_body//collection /resultMapOfType collection propertyposts javaTypeArrayList columnid ofTypePost selectselectPostsForBlog/可以读作 “posts 是一个存储 Post 的 ArrayList 集合” 。且在一般情况下MyBatis 可以推断 javaType 属性因此并不需要填写。 缓存Cache 一级缓存默认开启。SqlSession级别的缓存也叫本地缓存二级缓存基于namespace级别的缓存针对mapper cache, LRU, FIFO开启二级缓存需要在对于mapper上加入标签元素Cache即可当会话sqlSession提交commit或关闭close时一级缓存的数据才会提交到二级缓存中缓存顺序当查询业务来到DAO层时 先查看二级缓存再查看一级缓存最后再查数据库 动态Sql解决在定义Sql映射时拼接sql语句where子句条件SET子句多条语句foreach的编写。参考链接 If, choose, foreach, trim 分页limit Select * from user limit startIndex, pageSizeRowBoundsselectList (String statement, Object parameter, RowBounds rowBounds)Mybatis PageHelper 注解开发 参考链接
http://www.ho-use.cn/article/10823979.html

相关文章:

  • 中国门户网站建设重要性做网站需要学哪些语言
  • 招聘网站可做哪些推广方案广州网站开发 细致广州亦客网络
  • 新手怎么样学做网站简单的app开发
  • 织梦门户网站源码下载小型网站建设公司
  • 宝山做网站价格百度免费校园网站建设
  • 兼职网站建设收费网app开发
  • 德洲网站建设如何在网上推广信用卡
  • 亚马逊amz123seo引擎优化
  • 领先的响应式网站建设平台全网推广的方式
  • 如何做聚合类网站wordpress支持python吗
  • 网站改了模板被百度降权最便宜做个网站多少钱
  • 给钱做任务的网站重庆seo推广外包
  • 设计主题网站怎样看一个网站的信息吗
  • 织梦网站管理系统小说推广合作平台入口
  • 网站设计步骤大全萧山区建设工程质量监督站网站
  • 中国建设教育协会培训中心网站站优化
  • 做网站生意多吗短网址助手
  • 什么网站收录快关键词优化seo费用
  • 平台网站怎么优化中搜seo
  • 商城网站功能介绍建设网站要求有哪些
  • 门户网站制作平台视觉做的比较好的国外网站
  • 学校建设网站费用申请报告关键词排名优化系统
  • 网站维护一次一般要多久seo的目的是什么
  • 网站开发中 html网站自己优化
  • 链接提交百度站长平台wordpress重新配置ftp
  • 免费的网站域名查询方法有哪些加拿大28平台微信
  • 只有后端可以做网站吗wordpress标签3d
  • 企业制作网站一般多少钱网站首页制作代码
  • 网站开发包含哪些搜狗关键词排名查询
  • wordpress网站例qq引流推广平台