【Java高级工程师蜕变之路】002 自定义持久层框架

1、解析配置文件
1.1 数据库配置信息
1.2 sql的封装

2、构建SqlSessionFactory,注意这里的openSession方法

3、拿到SqlSesion
3.1 定义SqlSession基本方法
3.2 封装具体的执行逻辑,Executor
Execute的query方法就对应jdbc操作
3.3 优化,使用JDK动态代理避免statementId的硬编码

4、将SqlSession的操作封装到DAO层

源码

https://github.com/terwer/custom-mybatis.git

默认mapper方式

传统方式 https://github.com/terwer/custom-mybatis/tree/normal

原文地址:https://www.cnblogs.com/tangyouwei/p/15643847.html