• 源码学习之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

  • 相关阅读:
    cvCreateStructuringElementEx理解
    GNU_GSL相关
    粒子滤波(转)
    C++指针拷贝
    c++中的复制构造函数
    通过几道题目找自信
    C++网络编程基础
    linux system : install flash player
    ContentType一览
    O_RDWR O_CREAT等open函数标志位在哪里定义?(格式还要编译,答案在最后一段)
  • 原文地址:https://www.cnblogs.com/huilei/p/9768670.html
Copyright © 2020-2023  润新知