|
|
|
@ -22,9 +22,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
public class MixedSqlNode implements SqlNode {
|
|
|
|
@ -53,7 +53,7 @@ public class MixedSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
`org.apache.ibatis.scripting.xmltags.IfSqlNode#apply`
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
/**
|
|
|
|
@ -90,7 +90,7 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
- 解析`trim`标签
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 在解析`trim`的时候会往下解析下级标签
|
|
|
|
|
|
|
|
|
@ -107,7 +107,7 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
```JAVA
|
|
|
|
|
@Override
|
|
|
|
@ -161,17 +161,17 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
存在返回`true`
|
|
|
|
|
|
|
|
|
|
执行完成就得到了一个sql
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
继续执行`org.apache.ibatis.scripting.xmltags.DynamicSqlSource#getBoundSql`方法
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- 发送sql`org.apache.ibatis.executor.SimpleExecutor#doQuery`
|
|
|
|
|
|
|
|
|
@ -259,7 +259,7 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
- `org.apache.ibatis.executor.BaseExecutor#doQuery`
|
|
|
|
|
- `org.apache.ibatis.executor.SimpleExecutor#doQuery`
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
```java
|
|
|
|
|
private Statement prepareStatement(StatementHandler handler, Log statementLog) throws SQLException {
|
|
|
|
@ -276,7 +276,7 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- `org.apache.ibatis.executor.statement.BaseStatementHandler#prepare`
|
|
|
|
|
- `org.apache.ibatis.executor.statement.PreparedStatementHandler#instantiateStatement`
|
|
|
|
@ -330,7 +330,7 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
- 接下来需要考虑的问题是如何将`?`换成我们的参数`2`
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
- `org.apache.ibatis.executor.statement.StatementHandler#parameterize`
|
|
|
|
|
- `org.apache.ibatis.executor.statement.RoutingStatementHandler#parameterize`
|
|
|
|
@ -343,11 +343,11 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
这样就拿到了`value`的值
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
准备工作就绪了发送就可以了
|
|
|
|
|
|
|
|
|
@ -376,11 +376,11 @@ public class StaticTextSqlNode implements SqlNode {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
处理后结果如上
|
|
|
|
|
|
|
|
|
|