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

  • 相关阅读:
    yii2权限控制rbac之rule详细讲解
    yii2权限控制rbac之详细操作步骤
    安装 Autoconf, Automake & Libtool
    Linux查看物理CPU个数、核数、逻辑CPU个数
    Nginx端口占用问题
    Druid加密
    Ubuntu16.04安装Zabbix3.2(快速安装教程)
    飞冰ICE
    BeiDou开源项目
    Arthas开源项目
  • 原文地址:https://www.cnblogs.com/huilei/p/9768670.html
Copyright © 2011-2022 走看看