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

  • 相关阅读:
    寒假学习笔记12
    寒假学习笔记11
    寒假学习笔记10
    寒假学习笔记09
    JSoup简单测试
    App开发环境_Eclipse_20160927
    App开发环境_Eclipse_20160925
    ZC_源码编译真机烧写_20160424
    ZC_源码编译真机烧写_20160423
    sdk下载
  • 原文地址:https://www.cnblogs.com/huilei/p/9768670.html
Copyright © 2020-2023  润新知