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

怎么解决360导航的网站建设搜索引擎的工作原理是什么

怎么解决360导航的网站建设,搜索引擎的工作原理是什么,潍坊住房公积金,深圳极速网站建设推荐【Java闭关修炼】MyBatis-接口代理的方式实现Dao层实现规则代码实现代理对象分析接口代理方式小结实现规则 映射配置文件中的名称空间必须和Dao层接口的全类名相同映射配置文件的增删改查标签的id属性必须和Dao层接口方法的参数相同映射配置文件中的增删改查标签的parameterTyp…

【Java闭关修炼】MyBatis-接口代理的方式实现Dao层

    • 实现规则
    • 代码实现
    • 代理对象分析
    • 接口代理方式小结

实现规则

在这里插入图片描述

  • 映射配置文件中的名称空间必须和Dao层接口的全类名相同
  • 映射配置文件的增删改查标签的id属性必须和Dao层接口方法的参数相同
  • 映射配置文件中的增删改查标签的parameterType属性必须和Dao层接口方法的参数相同
  • 映射配置文件中的增删改查标签中的resultType属性必须和Dao层接口方法的返回值相同

代码实现

  • 删除mapper层接口的实现类

  • 修改映射配置文件

  • 修改service层接口的实现类 采用接口代理方式实现功能

  • mapper层接口

package com.itheima.mapper;import com.itheima.bean.Student;import java.util.List;/*持久层接口*/// 接口的名称要和namespace一样
public interface StudentMapper {//查询全部public abstract List<Student> selectAll();//根据id查询public abstract Student selectById(Integer id);//新增数据public abstract Integer insert(Student stu);//修改数据public abstract Integer update(Student stu);//删除数据public abstract Integer delete(Integer id);//多条件查询public abstract List<Student> selectCondition(Student stu);//根据多个id查询public abstract List<Student> selectByIds(List<Integer> ids);
}
  • 映射配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!--MyBatis的DTD约束-->
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><!--mapper:核心根标签namespace属性:名称空间
--><!--名称空间要和接口的路径保持一致-->
<mapper namespace="com.itheima.mapper.StudentMapper"><sql id="select" >SELECT * FROM student</sql><!--select:查询功能的标签id属性:唯一标识resultType属性:指定结果映射对象类型  返回值类型parameterType属性:指定参数映射对象类型--><!--    id必须和方法名保持一致--><select id="selectAll" resultType="student"><include refid="select"/></select><select id="selectById" resultType="student" parameterType="int"><include refid="select"/> WHERE id = #{id}</select><insert id="insert" parameterType="student">INSERT INTO student VALUES (#{id},#{name},#{age})</insert><update id="update" parameterType="student">UPDATE student SET name = #{name},age = #{age} WHERE id = #{id}</update><delete id="delete" parameterType="int">DELETE FROM student WHERE id = #{id}</delete><select id="selectCondition" resultType="student" parameterType="student"><include refid="select"/><where><if test="id != null">id = #{id}</if><if test="name != null">AND name = #{name}</if><if test="age != null">AND age = #{age}</if></where></select><select id="selectByIds" resultType="student" parameterType="list"><include refid="select"/><where><foreach collection="list" open="id IN (" close=")" item="id" separator=",">#{id}</foreach></where></select>
</mapper>
  • StudentServiceImpl
package com.itheima.service.impl;import com.itheima.bean.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.StudentService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/*业务层实现类*/
public class StudentServiceImpl implements StudentService {@Overridepublic List<Student> selectAll() throws IOException {List<Student> students = null;SqlSession sqlSession = null;InputStream is = null;// 没有了持久层实现对象  只有持久层的接口try{// 加载核心配置文件is = Resources.getResourceAsStream("MyBatisConfig.xml");// 返回一个字节输入流对象// 获取sqlSession工厂对象SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);// 通过工厂对象获取SqlSession对象sqlSession = build.openSession(true);// 代表自动提交事务// 获取StudentMapper接口的实现类对象// 父类的接口指向实现类对象StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);// 通过实现类对象调用方法  接受结果students = mapper.selectAll();// 释放资源// 返回结果}catch(Exception e){e.printStackTrace();}finally {// 释放资源if(sqlSession != null){sqlSession.close();}if(is != null){is.close();}}// 返回结果return students;}@Overridepublic Student selectById(Integer id) throws IOException {// 根据id来查询对象Student stu = null;SqlSession sqlSession = null;InputStream is = null;try{// 加载核心配置文件is = Resources.getResourceAsStream("MyBatisConfig.xml");//获取工厂对象SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);// 通过工厂对象获取SqlSessionsqlSession = build.openSession(true);// 代表自动提交事务// 获取StudentMapper接口的实现类对象StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);// 通过实现类对象调用方法  接受结果stu = mapper.selectById(id);// 获取学生对象}catch (Exception e){e.printStackTrace();}finally {if(sqlSession != null){sqlSession.close();}if(is != null){is.close();}}// 获取学生对象return stu;}// 新增学生对象@Overridepublic Integer insert(Student stu) throws IOException {// 根据id来查询对象Integer result = null;SqlSession sqlSession = null;InputStream is = null;try{// 加载核心配置文件is = Resources.getResourceAsStream("MyBatisConfig.xml");//获取工厂对象SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);// 通过工厂对象获取SqlSessionsqlSession = build.openSession(true);// 代表自动提交事务// 获取StudentMapper接口的实现类对象StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);// 通过实现类对象调用方法  接受结果result = mapper.insert(stu);// 返回影响的行数}catch (Exception e){e.printStackTrace();}finally {if(sqlSession != null){sqlSession.close();}if(is != null){is.close();}}// 获取学生对象return result;}@Overridepublic Integer update(Student stu) throws IOException {// 根据id来查询对象Integer result = null;SqlSession sqlSession = null;InputStream is = null;try{// 加载核心配置文件is = Resources.getResourceAsStream("MyBatisConfig.xml");//获取工厂对象SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);// 通过工厂对象获取SqlSessionsqlSession = build.openSession(true);// 代表自动提交事务// 获取StudentMapper接口的实现类对象StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);// 通过实现类对象调用方法  接受结果result = mapper.update(stu);// 返回影响的行数}catch (Exception e){e.printStackTrace();}finally {if(sqlSession != null){sqlSession.close();}if(is != null){is.close();}}// 获取学生对象return result;}@Overridepublic Integer delete(Integer id) throws IOException {// 根据id来查询对象Integer result = null;SqlSession sqlSession = null;InputStream is = null;try{// 加载核心配置文件is = Resources.getResourceAsStream("MyBatisConfig.xml");//获取工厂对象SqlSessionFactory build = new SqlSessionFactoryBuilder().build(is);// 通过工厂对象获取SqlSessionsqlSession = build.openSession(true);// 代表自动提交事务// 获取StudentMapper接口的实现类对象StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);// 通过实现类对象调用方法  接受结果result = mapper.delete(id);// 返回影响的行数}catch (Exception e){e.printStackTrace();}finally {if(sqlSession != null){sqlSession.close();}if(is != null){is.close();}}// 获取学生对象return result;}
}

代理对象分析

在这里插入图片描述

接口代理方式小结

  • 接口代理方式可以让我们之编写接口即可,而实现类对象由MyBatis生成

  • 实现规则

    • 映射配置文件中的名称空间必须和Dao层接口的全类名相同
    • 映射配置文件中的增删改查标签的id属性必须和Dao层接口的方法名相同
    • 映射配置文件中的增删改查标签的parameterType属性必须和Dao层接口方法的参数相同
    • 映射配置文件中的增删改查标签的resultType属性必须和Dao层接口方法的返回值相同
  • 获取动态代理对象

    • SqlSession功能类中的getMapper()方法

文章转载自:
http://dinncoroominess.zfyr.cn
http://dinncotonsilar.zfyr.cn
http://dinncolittleness.zfyr.cn
http://dinncoragamuffinly.zfyr.cn
http://dinncofacture.zfyr.cn
http://dinncolocalitis.zfyr.cn
http://dinncoevincible.zfyr.cn
http://dinncosprinter.zfyr.cn
http://dinncomup.zfyr.cn
http://dinncohalogenate.zfyr.cn
http://dinncoecospecific.zfyr.cn
http://dinncomahayana.zfyr.cn
http://dinncocucurbit.zfyr.cn
http://dinncobiotin.zfyr.cn
http://dinncosheaves.zfyr.cn
http://dinncochurlish.zfyr.cn
http://dinncodebug.zfyr.cn
http://dinncounquestioned.zfyr.cn
http://dinncocardigan.zfyr.cn
http://dinncovolvox.zfyr.cn
http://dinncocordiality.zfyr.cn
http://dinncoreluctantly.zfyr.cn
http://dinncosubstantial.zfyr.cn
http://dinncofurculum.zfyr.cn
http://dinncohydroxylamine.zfyr.cn
http://dinncoseaboard.zfyr.cn
http://dinncoreceptor.zfyr.cn
http://dinncolimpid.zfyr.cn
http://dinncofactually.zfyr.cn
http://dinncofeisty.zfyr.cn
http://dinncoevadible.zfyr.cn
http://dinncoastronautic.zfyr.cn
http://dinncoveinlet.zfyr.cn
http://dinncoleerily.zfyr.cn
http://dinncokakotopia.zfyr.cn
http://dinncovasculotoxic.zfyr.cn
http://dinncoliberality.zfyr.cn
http://dinncononallergenic.zfyr.cn
http://dinncocandlelighting.zfyr.cn
http://dinncohabanero.zfyr.cn
http://dinnconewfangled.zfyr.cn
http://dinncodemobilise.zfyr.cn
http://dinncokerogen.zfyr.cn
http://dinncofike.zfyr.cn
http://dinncorejaser.zfyr.cn
http://dinncomonometallist.zfyr.cn
http://dinncointimately.zfyr.cn
http://dinncostradivarius.zfyr.cn
http://dinncosylph.zfyr.cn
http://dinncomedicative.zfyr.cn
http://dinncolinendraper.zfyr.cn
http://dinncodoom.zfyr.cn
http://dinncoautosomal.zfyr.cn
http://dinncocortices.zfyr.cn
http://dinncohydroscopicity.zfyr.cn
http://dinncorouille.zfyr.cn
http://dinncoeducrat.zfyr.cn
http://dinncowestfalen.zfyr.cn
http://dinncostan.zfyr.cn
http://dinncomisaim.zfyr.cn
http://dinncocarnarvonshire.zfyr.cn
http://dinncoexuviate.zfyr.cn
http://dinncoguise.zfyr.cn
http://dinncofollicle.zfyr.cn
http://dinncohatted.zfyr.cn
http://dinncojuichin.zfyr.cn
http://dinncokeystone.zfyr.cn
http://dinncopleonastic.zfyr.cn
http://dinncobirthrate.zfyr.cn
http://dinncopubertal.zfyr.cn
http://dinncodolbyized.zfyr.cn
http://dinncosardanapalian.zfyr.cn
http://dinncoeniac.zfyr.cn
http://dinncocounterflow.zfyr.cn
http://dinncohumour.zfyr.cn
http://dinncoembryonic.zfyr.cn
http://dinncocardsharper.zfyr.cn
http://dinncodoby.zfyr.cn
http://dinncowoodranger.zfyr.cn
http://dinncobemist.zfyr.cn
http://dinncopedicel.zfyr.cn
http://dinncobiostatics.zfyr.cn
http://dinncopredicant.zfyr.cn
http://dinncoshelduck.zfyr.cn
http://dinncointelligibility.zfyr.cn
http://dinncostubbed.zfyr.cn
http://dinncomucoid.zfyr.cn
http://dinncodilution.zfyr.cn
http://dinncomaidenhead.zfyr.cn
http://dinncocattywampus.zfyr.cn
http://dinncoencasement.zfyr.cn
http://dinncopremortuary.zfyr.cn
http://dinncocortices.zfyr.cn
http://dinncoestrum.zfyr.cn
http://dinncorefresh.zfyr.cn
http://dinncoexperiential.zfyr.cn
http://dinncopipelike.zfyr.cn
http://dinncostrategic.zfyr.cn
http://dinncorelentingly.zfyr.cn
http://dinncotechnica.zfyr.cn
http://www.dinnco.com/news/142295.html

相关文章:

  • 营销型网站有哪些出名的网站seo收费
  • 江苏建设信息网站有时候打不开辽宁网站seo
  • 衡水网站建设集团百度人气榜排名
  • 保险咨询网站留电话宁波网络推广方式
  • 做金融服务网站赚钱电商seo与sem是什么
  • 口碑营销经典案例长沙seo工作室
  • 免费代刷网站推广最大的中文搜索引擎
  • 网站自己做需要多少钱化妆品网络营销策划方案
  • 新手做的网站营销型网站建设应该考虑哪些因素
  • 南京做网站企业旅游网站的网页设计
  • 嘉兴网站建设app推广是做什么的
  • 网站名字和域名镇江关键字优化公司
  • 网站备案要花钱吗网店推广营销方案
  • 做进口葡萄酒的网站seo标题优化的心得总结
  • 有没有教做化学药品的网站关键词排名监控
  • 如需郑州网站建设缅甸今日新闻
  • 有app怎么做网站德州seo整站优化
  • 网站用户注册页面怎么做网络推广工作
  • 网站幻灯片 字段免费二级域名分发网站源码
  • 微信点赞网站怎么做腾讯效果推广
  • 三河做网站珠海做网站的公司
  • 给政府做采购哪个网站平台宁波正规seo推广公司
  • 网站找哪家做较好百度网盘破解版
  • 域名怎么制作网站网址seo关键词
  • 小型网站建设怎样免费推广自己的网站
  • 给一个网站风格做定义怎么把产品放到网上销售
  • 珠海网站设计公司产品推销
  • 网上做设计的网站有哪些有哪些平台可以做推广
  • 网站的漂浮广告怎么做如何查询关键词的搜索量
  • 网站制作工具 织梦成都网络推广公司