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
getProperty:115, DynamicContext$ContextAccessor (org.apache.ibatis.scripting.xmltags)
getProperty:2671, OgnlRuntime (org.apache.ibatis.ognl)
getValueBody:114, ASTProperty (org.apache.ibatis.ognl)
evaluateGetValueBody:212, SimpleNode (org.apache.ibatis.ognl)
getValue:258, SimpleNode (org.apache.ibatis.ognl)
getValueBody:50, ASTNotEq (org.apache.ibatis.ognl)
evaluateGetValueBody:212, SimpleNode (org.apache.ibatis.ognl)
getValue:258, SimpleNode (org.apache.ibatis.ognl)
getValueBody:61, ASTAnd (org.apache.ibatis.ognl)
evaluateGetValueBody:212, SimpleNode (org.apache.ibatis.ognl)
getValue:258, SimpleNode (org.apache.ibatis.ognl)
getValue:470, Ognl (org.apache.ibatis.ognl)
getValue:434, Ognl (org.apache.ibatis.ognl)
getValue:44, OgnlCache (org.apache.ibatis.scripting.xmltags)
evaluateBoolean:32, ExpressionEvaluator (org.apache.ibatis.scripting.xmltags)
apply:34, IfSqlNode (org.apache.ibatis.scripting.xmltags)
apply:33, MixedSqlNode (org.apache.ibatis.scripting.xmltags)
apply:55, TrimSqlNode (org.apache.ibatis.scripting.xmltags)
apply:33, MixedSqlNode (org.apache.ibatis.scripting.xmltags)
getBoundSql:41, DynamicSqlSource (org.apache.ibatis.scripting.xmltags)
getBoundSql:292, MappedStatement (org.apache.ibatis.mapping)
query:81, CachingExecutor (org.apache.ibatis.executor)
invoke:-1, GeneratedMethodAccessor191 (sun.reflect)
invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
invoke:498, Method (java.lang.reflect)
invoke:63, Plugin (org.apache.ibatis.plugin)
query:-1, $Proxy398 (com.sun.proxy)
selectList:148, DefaultSqlSession (org.apache.ibatis.session.defaults)
selectList:141, DefaultSqlSession (org.apache.ibatis.session.defaults)
invoke:-1, GeneratedMethodAccessor199 (sun.reflect)
invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
invoke:498, Method (java.lang.reflect)
invoke:433, SqlSessionTemplate$SqlSessionInterceptor (org.mybatis.spring)
selectList:-1, $Proxy121 (com.sun.proxy)
selectList:230, SqlSessionTemplate (org.mybatis.spring)
executeForMany:137, MapperMethod (org.apache.ibatis.binding)
execute:75, MapperMethod (org.apache.ibatis.binding)
invoke:59, MapperProxy (org.apache.ibatis.binding)
// 这里进入MyBatis内部流程

find:-1, $Proxy355 (com.sun.proxy)
statics1:73, MyBusinessServiceImpl (com.xx.xx.service)
invoke:-1, MyBusinessServiceImpl$$FastClassBySpringCGLIB$$7c756e36 (com.xx.xx.service)
// 业务Service的代理

// 实际的数据库执行:

org.apache.ibatis.executor.BaseExecutor#queryFromDatabase

// 查看实际生成的SQL,也就是执行完了 <if test="xxx"> 这样的过滤后最终的 SQL:

org.apache.ibatis.scripting.xmltags.DynamicSqlSource#getBoundSql