zoukankan      html  css  js  c++  java
  • 源码学习之mybatis

    1、先看看俩种调用方式

    public static void main(String[] args) {
        SqlSessionFactory sqlSessionFactory;
        SqlSession session = null;
        try {
            String resource = "mybatis-config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resource);
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            session = sqlSessionFactory.openSession();
            HashMap<String,String> result = session.selectOne("selectBlog", 110);
            System.out.println("Result: "+result);
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            if(session != null){
                session.close();
            }
        }
    }
    

      

    public static void main(String[] args) {
        SqlSessionFactory sqlSessionFactory;
        SqlSession session = null;
        try {
            String resource = "mybatis-config.xml";
            InputStream inputStream = Resources.getResourceAsStream(resource);
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            session = sqlSessionFactory.openSession();
            ReleaseDTOMapper mapper = session.getMapper(ReleaseDTOMapper.class);
            
            HashMap<String,String> param = new HashMap<String,String>();
            param.put("STATE", "N");
            param.put("UPGRADE_ID","2");
            HashMap<String,String> result = mapper.getReleaseNote(param);
            System.out.println("Result: "+result);
            List<HashMap<String,String>> rs = mapper.getUpgradeNote();
            for(HashMap<String,String> r : rs){
                System.out.println("Result: "+r);
            }            
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            if(session != null){
                session.close();
            }
        }
    }
    

      

    2 整体结构

     

    其他知识点

    mybatis 一二级缓存

    Spring-mybatis 缓存失效问题

    ref

    https://blog.csdn.net/Vera1114/article/details/78763322

    https://www.jianshu.com/p/73ee8caddc68

    https://baijiahao.baidu.com/s?id=1595688310049388329&wfr=spider&for=pc

    http://www.crazyant.net/2022.html

    https://blog.csdn.net/chenyao1994/article/details/79233725

  • 相关阅读:
    Timer 实现2秒4秒连环炸
    Java中的注解
    PHP连接打印机
    php同步mysql两个数据库中表的数据
    thinkphp 两表、三表联合查询
    ereg/eregi报错处理办法
    ThinkPHP3.2判断手机端访问并设置默认访问模块的方法
    使用PHP获取时间今天 明天 昨天 时间戳的详解
    jquery获取radio和select选中值
    php开启mysqli扩展之后如何连接数据库
  • 原文地址:https://www.cnblogs.com/huilei/p/9768670.html
Copyright © 2011-2022 走看看