Mybatis源码学习-类图
2021-03-04 10:42:09 0 举报
有关Mybatis相关源码类图的总结
作者其他创作
大纲/内容
1
Executor {abstract}
session
TypeHandlerRegistry
PlainMethodInvoker
- mapperMethod MapperMethod
Configuration类图
*
ParameterExpression
CachingExecutor
- delegate Executor- tcm TransactionalCacheManager
SqlSource {abstract}
+ getBoundSql(Object parameterObject) BoundSql
StatementHandler {abstract}
+ getParameterHandler() :ParameterHandler
SqlSourceBuilder
PreparedStatementHandler
scripting
SqlSessoin {abstract}
事务管理
DefaultParameterHandler
- typeHandlerRegistry TypeHandlerRegistry- mappedStatement MappedStatement- parameterObject Object- configuration Configuration
StaticTextSqlNode
- test String
ParameterHandler {abstract}
+ getParameterObject() : Object+ setParameters(PreparedStatement ps) :void
ParamMap
+ get(Object key)
StaticSqlSource
- configuration Configuration- sql String- parameterMappings List<ParameterMapping>
缓存管理
mybatis架构图
SqlSessionFactory
BaseBuilder类图
BaseBuilder
- configuration Configuration
ObjectTypeHandler
SqlSessionManager
- sqlSessionFactory:SqlSessionFactory- sqlSessionProxy:SqlSession- localSqlSession: ThreadLocal<SqlSession>
JDBC
BaseStatementHandler
- resultSetHandler ResultSetHandler
SqlNode {abstract}
+ apply(DynamicContext context) boolean
mybatis包架构图
Configuration
UnknownTypeHandler
- typeHandlerRegistry typeHandlerRegistry
SqlNode与XMLScriptBuilder类图
BaseTypeHandler<T> {abstract}
# configuration Configuration
exceptions
ReuseExecutor
数据处理层
BoundSql
- parameterMappings List<ParameterMapping>
ChooseSqlNode
- defaultSqlNode SqlNode- ifSqlNodes List<SqlNode>
DefaultResultSetHandler
- executor Executor- configuration Configuration- mappedStatement MappedStatement- rowBounds RowBounds- parameterHandler ParameterHandler- resultHandler ResultHandler<?>- boundSql BoundSql- typeHandlerRegistry TypeHandlerRegistry- objectFactory ObjectFactory- reflectorFactory ReflectorFactory- useConstructorMappings boolean
MapperRegistry
+ selectOne(String statement):T+ insert(String statement):int+ update(String statement):int+ delete(String statement):int+ getMapper(Class<T> type):T
XNode
- node Node- name String- body String- attributes Properties- variables Properties- xpathParser XPathParser
结果映射配置结果映射解析结果数据拷贝
SimpleExecutor
MapperBuilderAssistant
mapping
BaseExecutor
# transaction Transaction# wrapper Executor# deferredLoads ConcurrentLinkedQueue<DeferredLoad># localCache PerpetualCache# localOutputParameterCache PerpetualCache# configuration Configuration# queryStack int# closed boolean
MapperRegistry类图
TypeHandler<T> {abstract}
数据库
builder
SqlSessoinFactory {abstract}
基础支撑层
DefaultSqlSession
- configuration:Configuration- executor:Executor - autoCommit:boolean- dirty:boolean- cursorList:List<Cursor<?>>
plugin
结果映射
mybatis-config.xml配置文件xxxMapper.xml映射文件
SqlCommand
- name String - type SqlCommandType
SetSqlNode
- COMMA List<String>
datasource
- currentNamespace String- resource String- currentCache Cache- unresolvedCacheRef boolean
XMLStatementBuilder
- builderAssistant MapperBuilderAssistant
配置加载
XPathParse类关系图
MappedStatement
- configuration Configuration- resource String- id String- databaseId String- useCache boolean- resultMaps List<ResultMap>- statementType StatementType
TypeReference<T> {abstract}
- rawType Type
ResultMap
- configuration Configuration- id String- type Class<?>- resultMappings List<ResultMapping>- idResultMappings List<ResultMapping>- constructorResultMappings List<ResultMapping>- propertyResultMappings List<ResultMapping>- mappedColumns Set<String>- mappedProperties Set<String>- discriminator Discriminator- hasNestedResultMaps boolean- hasNestedQueries boolean- autoMapping Boolean
WhereSqlNode
- prefixList List<String>
连接管理
解析mybatis-config.xml全局配置文件解析Mapper.xml文件解析
- configuration:Configuration
解析配置
DefaultSqlSessionFactory
- configuration: Configuration
binding
ForEachSqlNode
+ ITEM_PREFIX String- evaluator ExpressionEvaluator- collectionExpression String- contents SqlNode- open String- close String- separator String- item String- index String- configuration Configuration
DynamicSqlSource
- configuration Configuration- rootSqlNode SqlNode
XMLConfigBuilder
- parsed boolean- parser XPathParser- environment String- localReflectorFactory ReflectorFactory
CallableStatementHandler
MapperProxy类关系图
transation
+ getBoundSql() : BoundSql
VarDeclSqlNode
- name String- expression String
MethodSignature
- returnsMany boolean- returnsMap boolean- returnsVoid boolean- returnsCursor boolean- returnsOptional boolean- returnType Class<?>- mapKey String- resultHandlerIndex Integer- rowBoundsIndex Integer- paramNameResolver ParamNameResolver
ParameterMapping
- configuration Configuration- typeHandler TypeHandler<?>
SqlSession与SqlSessionFactory类图
结果映射Map、基本类型、pojo、list等
Excutor
ParameterMapping.Builder
- parameterMapping ParameterMapping
XMLMapperBuilder
io
- builderAssistant MapperBuilderAssistant- context XNode- requiredDatabaseId String
annonation
BoundSql&SqlSource类图
RawSqlSource
- sqlSource SqlSource
+ getBoundSql() :BoundSql
Executor
ResultHandler {abstract}
type
XMLScriptBuilder
BaseStatementHandler {abstract}
# configuration Configuration# objectFactory ObjectFactory# typeHandlerRegistry TypeHandlerRegistry# resultSetHandler ResultSetHandler# parameterHandler ParameterHandler# executor Executor# mappedStatement MappedStatement# rowBounds RowBounds# boundSql BoundSql
ResultSetHandler {abstract}
TextSqlNode
- test String- injectionFilter Pattern
sql执行
+ selectOne(String statement):T+ insert(String statement):int+ update(String statement):int+ delete(String statement):int
reflection
MapperProxy
# mapperRegistry MapperRegistry
- configuration Configuration- property String- mode ParameterMode- javaType Class<?>- jdbcType JdbcType- numericScale Integer- typeHandler TypeHandler<?>- resultMapId String- jdbcTypeName String- expression String
IfSqlNode
- evaluator ExpressionEvaluator- test String- contents SqlNode
ClosedExecutor
ResultMap类图
MappedStatement类图
logging
接口层
cache
parsing
MapperProxyFactory
ResultSetHandler类图
ParameterMappingTokenHandler
- buildParameterMapping(String content) : ParameterMapping
ResultMapping
- configuration Configuration- property String- column String- javaType Class<?>- jdbcType Class<?>- typeHandler TypeHandler<?>- nestedResultMapId String- nestedQueryId String- notNullColumns Set<String>- columnPrefix String- flags List<ResultFlag>- composites List<ResultMapping>- resultSet String- foreignColumn String- lazy boolean
RoutingStatementHandler
- delegate StatementHandler
MapperMethod
Executor类图
TypeHandler类图
ProviderSqlSource
- configuration Configuration- providerType Class<?>- languageDriver LanguageDriver- mapperMethod Method- providerMethod Method- providerMethodArgumentNames String[]- providerMethodParameterTypes Class<?>[]- providerContext ProviderContext- providerContextIndex Integer
+ newParameterHandler(....) : ParameterHandler
+ openSession():SqlSession+ openSession(boolean autoCommit):SqlSession
StatementHandler类关系图
SimpleStatementHandler
获取配置接口
DefaultMethodInvoker
- methodHandle MethodHandle
日志管理
输入映射Map、基本类型、pojo等
SqlSource
+ getBoundSql(Object parameterObject) : BoundSql
XPathParse
- document Documnet- validation boolean- entityResolver EntityResolver- variables Properties- xpath XPath
executor
MapperMethodInvoker {abstract}
TrimSqlNode
- contents SqlNode- prefix String- suffix String- prefixesToOverride List<String>- suffixesToOverride List<String>- configuration Configuration
数据更新接口
数据查询接口
MixedSqlNode
- contents List<SqlNode>
LanguageDriver
+ createParameterHandler(....) : ParameterHandler
IntegerTypeHandler
- command SqlCommand- method MethodSignature
ResultMapResolver
- assistant MapperBuilderAssistant - id String- type Class<?>- extend String- discriminator Discriminator- resultMappings List<ResultMapping>- autoMapping Boolean
数据删除接口
BatchExecutor
- statementList List<Statement>- batchResultList List<BatchResult>- currentSql String- currentStatement MappedStatement
ParameterMapping类图
- configuration Configuration- typeAliasRegistry TypeAliasRegistry- typeHandlerRegistry TypeHandlerRegistry
SqlSession
参数处理
参数映射SQL获取SQL解析
ParameterHandler类图
Mybatis架构流程图
0 条评论
下一页