2024年3月6日
sqlCommand Author: HuiFer Description: 该文介绍 mybatis sqlCommand 类的源码 源码阅读工程: SourceHot-Mybatis org.apache.ibatis.binding.MapperMethod.SqlCommand 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 /** * 核心内容: sql id , Sql 类型 */ public static class SqlCommand { /** * sql id */ private final String name; /** * sql 类型……
阅读全文
2024年3月6日
ParamNameResolver 源码解析 Author: HuiFer Description: 该文介绍 mybatis @Param 注解和ParamNameResolver 源码阅读工程: SourceHot-Mybatis 源码 org.apache.ibatis.reflection.ParamNameResolver 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95……
阅读全文
2024年3月6日
Mybatis ObjectWrapper Author: HuiFer 源码阅读工程: SourceHot-Mybatis 源码位于: org.apache.ibatis.reflection.wrapper.ObjectWrapper‘ 类图: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69……
阅读全文
2024年3月6日
MethodSignature Author: HuiFer Description: 该文介绍 mybatis MethodSignature 类 源码阅读工程: SourceHot-Mybatis org.apache.ibatis.binding.MapperMethod.MethodSignature 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120……
阅读全文
2024年3月6日
Mybatis MetaObject Author: HuiFer 源码阅读工程: SourceHot-Mybatis 源码位于:org.apache.ibatis.reflection.MetaObject 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84……
阅读全文
2024年3月6日
MapperMethod Author: HuiFer Description: 该文介绍 mybatis MapperMethod 源码 源码地址: org.apache.ibatis.binding.MapperMethod,核心方法是execute 源码阅读工程: SourceHot-Mybatis 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 /** * CRUD 不同的执行……
阅读全文
2024年3月6日
Mybatis DyanmicSqlSourcce Author: HuiFer 源码阅读工程: SourceHot-Mybatis org.apache.ibatis.scripting.xmltags.DynamicSqlSource org.apache.ibatis.scripting.xmltags.DynamicContext.DynamicContext 1 2 3 4 5 6 7 8 9 <select id="list" resultType="com.huifer.mybatis.entity.HsSell"> select * from hs_sell <trim prefix="WHERE" prefixOverrides="AND |OR"> <if test="ID != null"> and ID = #{ID,jdbcType=INTEGER} </if> </trim> </select> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public class MixedSqlNode implements SqlNode { private final List<SqlNode> contents; public MixedSqlNode(List<SqlNode> contents) { this.contents = contents; } @Override public boolean apply(DynamicContext context) { // 调用 salNode 对象本身的 apply 方法解析 sql contents.forEach(node -> node.apply(context)); return true; } } 根据 mapper.xml 文件中的代码流程 需要走 org.apache.ibatis.scripting.xmltags.StaticTextSqlNode#apply org.apache.ibatis.scripting.xmltags.TrimSqlNode#apply org.apache.ibatis.scripting.xmltags.IfSqlNode#apply 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18……
阅读全文
2024年3月6日
Mybatis DataSource Author: HuiFer Description: 该文介绍 mybatis DataSource 源码 源码阅读工程: SourceHot-Mybatis org.apache.ibatis.datasource.DataSourceFactory 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 /** * 数据源工厂 * @author Clinton Begin */ public interface DataSourceFactory { /** * 设置 dataSource 属性 * @param props */ void setProperties(Properties props); /** * 获取 dataSource * @return {@link DataSource} */ DataSource getDataSource(); } 类图如下 setProperties会将下列标签放入datasource中 1 2 3 4 5 6 <dataSource type="POOLED"> <property name="driver" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=false"/> <property name="username" value="mybatis"/> <property name="password" value="mybatis"/>……
阅读全文
2024年3月6日
Mybatis Cursor Author: HuiFer Description: 该文介绍 mybatis Cursor 源码 源码阅读工程: SourceHot-Mybatis Cursor 源码位置:org.apache.ibatis.cursor.Cursor 继承Iterable说明是一个迭代器,继承Closeable说明有一个东西需要关闭 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 public interface Cursor<T> extends Closeable, Iterable<T> { /** * 游标开始从数据库……
阅读全文
2024年3月6日
Mybatis Alias Author: HuiFer Description: 该文介绍 mybatis Alias 源码 源码阅读工程: SourceHot-Mybatis 源码位置 :org.apache.ibatis.type.Alias 与 Alias 相关的一个方法org.apache.ibatis.type.TypeAliasRegistry.registerAlias(java.lang.String, java.lang.Class<?>)(别名注册) 1 2……
阅读全文