MyBatis Source Code Reading

MyBatis Source Code Reading, 做一个掌握底层技术的Java程序员!update@20201224

零散知识

SqlSessionFactoryBean

In base MyBatis, the SqlSessionFactory is built using SqlSessionFactoryBuilder. In MyBatis-Spring, SqlSessionFactoryBean is used instead. read

代码片段

    reader = Resources.getResourceAsReader("config/Configure.xml");
    sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
//openSession()需要后动提交, autocommit是false
    SqlSession session = sqlSessionFactory.openSession();
    IUser userMapper = session.getMapper(IUser.class);
    System.out.println("Test insert start...");
    User user = new User();
    user.setId(0);
    user.setName("Google");
    userMapper.insertUser(user);
    session.commit();

SqlSessionTemplate

为什么Mapper没有实现类

动态代理获取到实现类, IUser userMapper = session.getMapper(IUser.class);类似这个UserService proxy = (UserService) Proxy.newProxyInstance(classLoader, interfaces, logHandler);

某司改过的版本

为什么没有session.commit()?

系统阅读

Read list:

Search

    Categories Cloud

    Life Linux C/CPP Database Web Benchmarks Software Data Python TCP/IP Financial Stock Bug Golang Rust General Infrastructure TODO Movie Multitenancy Java Ant Algorithm Fastjson Death Build Deploy Education India Aamir Khan Society Female Learning Method OJ Interviewee Interviewer AVL Tree MyBatis Code Reading Design Diary Dating Heap Data Structure Summary Reading Love Claire Mcfall Ferryman Zodiac Astrology Chinese Calculator flink Dubbo docker redis

    Table of Contents