Compare commits
1 Commits
main
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b7bcca8e99 |
@ -156,14 +156,14 @@
|
||||
- [Mybatis-Alias](/docs/Mybatis/核心处理层/Mybatis-Alias.md)
|
||||
- [Mybatis-Cursor](/docs/Mybatis/核心处理层/Mybatis-Cursor.md)
|
||||
- [Mybatis-DataSource](/docs/Mybatis/核心处理层/Mybatis-DataSource.md)
|
||||
- [Mybatis-DynamicSqlSource](/docs/Mybatis/核心处理层/Mybatis-DynamicSqlSource.md)
|
||||
- [Mybatis-DyanmicSqlSourcce](/docs/Mybatis/核心处理层/Mybatis-DyanmicSqlSourcce.md)
|
||||
- [Mybatis-MapperMethod](/docs/Mybatis/核心处理层/Mybatis-MapperMethod.md)
|
||||
- [Mybatis-MetaObject](/docs/Mybatis/核心处理层/Mybatis-MetaObject.md)
|
||||
- [Mybatis-MethodSignature](/docs/Mybatis/核心处理层/Mybatis-MethodSignature.md)
|
||||
- [Mybatis-ObjectWrapper](/docs/Mybatis/核心处理层/Mybatis-ObjectWrapper.md)
|
||||
- [Mybatis-ParamNameResolver](/docs/Mybatis/核心处理层/Mybatis-ParamNameResolver.md)
|
||||
- [Mybatis-SqlCommand](/docs/Mybatis/核心处理层/Mybatis-SqlCommand.md)
|
||||
- [Mybatis-GenericTokenParser](/docs/Mybatis/核心处理层/Mybatis-GenericTokenParser.md)
|
||||
- [Mybats-GenericTokenParser](/docs/Mybatis/核心处理层/Mybats-GenericTokenParser.md)
|
||||
|
||||
## Netty
|
||||
|
||||
|
@ -576,4 +576,4 @@ TypeHandlerRegistry 其实就是一个容器,前面注册了一堆东西,也
|
||||
}
|
||||
```
|
||||
|
||||
除了 Mybatis 本身自带的 TypeHandler 实现,我们还可以添加自定义的 TypeHandler 实现类,在配置文件 mybatis-config.xml 中的 <typeHandler> 标签下配置好 自定义 TypeHandler,Mybatis 就会在初始化时解析该标签内容,完成 自定义 TypeHandler 的注册。
|
||||
除了 Mabatis 本身自带的 TypeHandler 实现,我们还可以添加自定义的 TypeHandler 实现类,在配置文件 mybatis-config.xml 中的 <typeHandler> 标签下配置好 自定义 TypeHandler,Mybatis 就会在初始化时解析该标签内容,完成 自定义 TypeHandler 的注册。
|
||||
|
@ -213,7 +213,7 @@ class HfReflectorTest {
|
||||
Map<String, Method> uniqueMethods = new HashMap<>();
|
||||
Class<?> currentClass = clazz;
|
||||
while (currentClass != null && currentClass != Object.class) {
|
||||
// getDeclaredMethods 获取 public ,private , protected 方法
|
||||
// getDeclaredMethods 获取 public ,private , protcted 方法
|
||||
addUniqueMethods(uniqueMethods, currentClass.getDeclaredMethods());
|
||||
|
||||
// we also need to look for interface methods -
|
||||
|
@ -85,7 +85,7 @@ MyBatis 提供的缓存功能,分别为一级缓存和二级缓存。BaseExecu
|
||||
|
||||
为了避免上述问题,MyBatis 会在 Executor 对象中建立一个简单的一级缓存,将每次查询的结果集缓存起来。在执行查询操作时,会先查询一级缓存,如果存在完全一样的查询情况,则直接从一级缓存中取出相应的结果对象并返回给用户,减少数据库访问次数,从而减小了数据库的压力。
|
||||
|
||||
一级缓存的生命周期与 SqlSession 相同,其实也就与 SqISession 中封装的 Executor 对象的生命周期相同。当调用 Executor 对象的 close()方法时(断开连接),该 Executor 对象对应的一级缓存就会被废弃掉。一级缓存中对象的存活时间受很多方面的影响,例如,在调用 Executor 的 update()方法时,也会先清空一级缓存。一级缓存默认是开启的,一般情况下,不需要用户进行特殊配置。
|
||||
一级缓存的生命周期与 SqlSession 相同,其实也就与 SqISession 中封装的 Executor 对象的生命周期相同。当调用 Executor 对象的 close()方法时(断开连接),该 Executor 对象对应的一级缓存就会被废弃掉。一级缓存中对象的存活时间受很多方面的影响,例如,在调用 Executor 的 update()方法时,也会先请空一级缓存。一级缓存默认是开启的,一般情况下,不需要用户进行特殊配置。
|
||||
|
||||
### 1.2 一级缓存的管理
|
||||
|
||||
@ -375,7 +375,7 @@ public class SimpleExecutor extends BaseExecutor {
|
||||
|
||||
ReuseExecutor 提供了 Statement 复用的功能,ReuseExecutor 中通过 statementMap 字段缓存使用过的 Statement 对象,key 是 SQL 语句,value 是 SQL 对应的 Statement 对象。
|
||||
|
||||
ReuseExecutor.doQuery()、doQueryCursor()、doUpdate()方法的实现与 SimpleExecutor 中对应方法的实现一样,区别在于其中调用的 prepareStatement()方法,SimpleExecutor 每次都会通过 JDBC 的 Connection 对象创建新的 Statement 对象,而 ReuseExecutor 则会先尝试重用 StatementMap 中缓存的 Statement 对象。
|
||||
ReuseExecutor.doQuery()、doQueryCursor()、doUpdate()方法的实现与 SimpleExecutor 中对应方法的实现一样,区别在于其中调用的 prepareStatement()方法,SimpleExecutor 每次都会通过 JDBC 的 Connection 对象创建新的 Statement 对象,而 ReuseExecutor 则会先尝试重用 StaternentMap 中缓存的 Statement 对象。
|
||||
|
||||
```java
|
||||
// 本map用于缓存使用过的Statement,以提升本框架的性能
|
||||
@ -438,7 +438,7 @@ ReuseExecutor.doQuery()、doQueryCursor()、doUpdate()方法的实现与 SimpleE
|
||||
|
||||
(3)缓存预编译
|
||||
|
||||
预编译语句被 DB 的编译器编译后的执行代码被缓存下来,那么下次调用时只要是相同的预编译语句就不需要重复编译,只要将参数直接传入编译过的语句执行代码中(相当于一个函数)就会得到执行。并不是所有预编译语句都一定会被缓存,数据库本身会用一种策略(内部机制)。
|
||||
预编译语句被 DB 的编译器编译后的执行代码被缓存下来,那么下次调用时只要是相同的预编译语句就不需要重复编译,只要将参数直接传入编译过的语句执行代码中(相当于一个函数)就会得到执行。并不是所以预编译语句都一定会被缓存,数据库本身会用一种策略(内部机制)。
|
||||
|
||||
(4) 预编译的实现方法
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class JndiDataSourceFactory implements DataSourceFactory {
|
||||
## PooledDataSource
|
||||
|
||||
```java
|
||||
protected int poolMaximumActiveConnections = 10;
|
||||
protected int poolMaximumActiveConnections = 10;
|
||||
protected int poolMaximumIdleConnections = 5;
|
||||
protected int poolMaximumCheckoutTime = 20000;
|
||||
protected int poolTimeToWait = 20000;
|
||||
@ -155,7 +155,7 @@ public class PooledDataSourceFactory extends UnpooledDataSourceFactory {
|
||||
|
||||
}
|
||||
|
||||
// 初始化
|
||||
// 初始化
|
||||
public PooledDataSource() {
|
||||
dataSource = new UnpooledDataSource();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Mybatis DynamicSqlSource
|
||||
# Mybatis DyanmicSqlSourcce
|
||||
|
||||
- Author: [HuiFer](https://github.com/huifer)
|
||||
- 源码阅读工程: [SourceHot-Mybatis](https://github.com/SourceHot/mybatis-read.git)
|
||||
@ -257,7 +257,7 @@ public class StaticTextSqlNode implements SqlNode {
|
||||
Statement stmt;
|
||||
// 数据库连接
|
||||
Connection connection = getConnection(statementLog);
|
||||
// stmt 创建
|
||||
// stms 创建
|
||||
// org.apache.ibatis.executor.statement.BaseStatementHandler.prepare
|
||||
stmt = handler.prepare(connection, transaction.getTimeout());
|
||||
// 参数放入
|
@ -90,7 +90,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有 resultHandler
|
||||
* 是否uresultHandler
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
@ -298,7 +298,7 @@ public class ProxyCreatorSupport extends AdvisedSupport {
|
||||
}
|
||||
```
|
||||
|
||||
可以看到其根据目标对象是否为接口,而决定是使用 JDK 动态代理 还是 CGLIB 去生成代理对象,而 AopProxy 接口的实现类也只有 JdkDynamicAopProxy 和 CglibAopProxy 这两个。
|
||||
可以看到其根据目标对象是否实现了接口,而决定是使用 JDK 动态代理 还是 CGLIB 去生成代理对象,而 AopProxy 接口的实现类也只有 JdkDynamicAopProxy 和 CglibAopProxy 这两个。
|
||||
|
||||
### 2.5 JDK 动态代理 生成 AopProxy 代理对象
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
### 服务提供方
|
||||
|
||||
- 服务提供方需要准备**接口**、**接口实现类**
|
||||
- 服务提供方需要准备**接口**、**接口实现泪**
|
||||
- 接口
|
||||
|
||||
```java
|
||||
|
24
package-lock.json
generated
24
package-lock.json
generated
@ -1481,9 +1481,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
|
||||
"integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
|
||||
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
@ -1528,19 +1528,27 @@
|
||||
}
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
|
||||
"integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
|
||||
"version": "1.16.2",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
|
||||
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
|
||||
"dependencies": {
|
||||
"encodeurl": "~1.0.2",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "0.18.0"
|
||||
"send": "0.19.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/serve-static/node_modules/encodeurl": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/set-blocking": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
|
||||
|
Loading…
x
Reference in New Issue
Block a user