java自学网(www.javazx.com)-java论坛,java电子书推荐:《深入浅出MyBatis技术原理与实战》' k2 p8 [/ y5 j1 W* v9 \, e
java电子书推荐理由:MyBatis的书籍,为了填补这一空白本书主要介绍了Java MyBatis技术。本书详细介绍了MyBatis的基础组成、配置、映射器、动态SQL,教会读者正确使用MyBatis,书中包含大量的实例,使读者可以参考。接着介绍了MyBatis的运行原理和插件开发并配有一个完整的插件例子。为了增加实用性,作者还介绍了MyBatis-Spring项目,使得读者能够学习到如何把MyBatis整合到Spring项目中,最后作者还将讲解一些常用实例,比如Blob字段、文件上传、批量、动态表名等实用场景,让读者能够参考和注意一些细节的问题。5 \: x f: S( D3 I2 N
; \" Z7 S& |) ? W: V& P* M
4 H; }) J( k$ f: G, f6 C作者:杨开振 著+ E& l# w" d, N- Y5 x8 P* d
出版社:电子工业出版社4 F$ J$ a0 w6 I7 X4 {- Z
出版时间:2016年8月
! A; w" h0 B, H$ ?
" B+ n# p; ^+ f! W6 t$ y4 d, w3 B0 [& u7 i) a9 o" I* Y
5 y5 Z9 G8 D; v/ C+ g" n8 o" E1 g, U9 e, ~+ ]: R6 T9 `" b% x% B" \
. x( X5 x; _( A8 [) ^6 F5 C2 _java电子书目录:( }6 o' U" S% M0 p8 W1 e
第1 章 MyBatis 简介.................................................................................................................................. 1, t& Z) G. V) R+ `. q1 t* a
1.1 传统的JDBC 编程........................................................................................................................ 1
t" P- J- R. w1.2 ORM 模型....................................................................................................................................... 4
$ a6 v, f$ v. }1 o) W1.3 Hibernate.................................................................................................................................... 49 |2 b( `6 Z8 }, a# d5 R
1.4 MyBatis ..................................................................................................................................... 99 \& {' D) h% T4 X2 u
1.5 什么时候用MyBatis....................................................................................................................123 G8 y% h: ]! H9 G- K2 ?
第2 章 MyBaits 入门.........................................................................................................................13
. [* r9 E' V) @' v; n& n2.1 开发环境准备...............................................................................................................................13
9 R. O' m8 f% y2.1.1 下载MyBatis .........................................................................................................................13
, G2 Y' x1 V' [. K+ t2.1.2 搭建开发环境........................................................................................................................14- L; ?- O: F z' [8 m
2.2 MyBatis 的基本构成....................................................................................................................15
3 Q7 G- }/ r1 S/ l2.2.1 构建SqlSessionFactory..........................................................................................................15
! ], f7 m3 N- ~( z7 D7 A2.2.2 创建SqlSession.....................................................................................................................19
# R0 ?9 u, O# m2.2.3 映射器...................................................................................................................................21
( ~) j. K3 `4 M; i2.3 生命周期.........................................................................................................................................26: c4 b1 \0 }& F# ?' R: R8 c, B
2.3.1 SqlSessionFactoryBuilder.......................................................................................................27
$ B8 j! P3 c2 |+ I6 O8 t2.3.2 SqlSessionFactory..................................................................................................................27
: b6 p, P, S' T! ^3 N2.3.3 SqlSession..............................................................................................................................279 O. `( U0 s% k0 g
2.3.4 Mapper...................................................................................................................................28/ M; E& Z2 @5 D, r5 @/ n
2.4 实例...........................................................................................................................................29( s5 @) ~1 a* k$ O' ?- R
第3 章 配置.........................................................................................................................................37
$ r5 v' |5 B1 {/ A; U9 w4 m3.1 properties 元素...............................................................................................................................38
; O0 Y9 V: }, V' o, E& ?3.1.1 property 子元素......................................................................................................................38
3 J* S" e# x( P- j9 @7 G3.1.2 properties 配置文件...............................................................................................................39
5 ], {( P6 a% f2 A+ N3.1.3 程序参数传递........................................................................................................................39
9 z: J" z% ?( I3.1.4 优先级...................................................................................................................................40
, |" f( {* h) F$ z3.2 设置.........................................................................................................................................41
$ g% I9 J# {" s/ @0 x- P3.3 别名........................................................................................................................................44
3 z( A0 Y7 M! d+ \; q' ?' b) P5 T, k* Q" h! u# j9 D: v7 V
3.3.1 系统定义别名........................................................................................................................44 3.3.2 自定义别名............................................................................................................................47 3.4 typeHandler 类型处理器.............................................................................................................48 3.4.1 系统定义的typeHandler........................................................................................................49 3.4.2 自定义typeHandler................................................................................................................51 3.4.3 枚举类型typeHandler............................................................................................................55 3.5 ObjectFactory.................................................................................................................................62 3.6 插件..................................................................................................................................................65 3.7 environments 配置环境...............................................................................................................65 3.7.1 概述.......................................................................................................................................65 3.7.2 数据库事务............................................................................................................................66 3.7.3 数据源...................................................................................................................................67 3.8 databaseIdProvider 数据库厂商标识.......................................................................................68 3.8.1 使用系统默认规则................................................................................................................68 3.8.2 不使用系统默认规则............................................................................................................69 3.9 引入映射器的方法.......................................................................................................................71 第4 章映射器..............................................................................................................................................73 4.1 映射器的主要元素.......................................................................................................................73 4.2 select 元素......................................................................................................................................74 4.2.1 概述.......................................................................................................................................74 4.2.2 简易数据类型的例子............................................................................................................75 4.2.3 自动映射...............................................................................................................................76$ e3 h+ W; h' Q' r
4.2.4 传递多个参数........................................................................................................................78 4.2.5 使用resultMap 映射结果集..................................................................................................81 4.3 insert 元素......................................................................................................................................82 4.3.1 概述.......................................................................................................................................82 4.3.2 主键回填和自定义................................................................................................................83 4.4 update 元素和delete 元素..........................................................................................................85 4.5 参数..................................................................................................................................................85 4.5.1 参数配置...............................................................................................................................86 4.5.2 存储过程支持........................................................................................................................86 4.5.3 特殊字符串替换和处理(#和$).........................................................................................87 4.6 sql 元素...........................................................................................................................................88 4.7 resultMap 结果映射集.................................................................................................................89 4.7.1 resultMap 元素的构成...........................................................................................................89 4.7.2 使用map 存储结果集............................................................................................................91 4.7.3 使用POJO 存储结果集.........................................................................................................91 4.7.4 级联.......................................................................................................................................92 4.8 缓存cache ....................................................................................................................................113 4.8.1 系统缓存(一级缓存和二级缓存)...................................................................................113 4.8.2 自定义缓存..........................................................................................................................117 第5 章 动态SQL ......................................................................................................................................119 5.1 概述................................................................................................................................................119 5.2 if 元素............................................................................................................................................120 5.3 choose、when、otherwise 元素..............................................................................................120 5.4 trim、where、set 元素..............................................................................................................121 5.5 foreach 元素.................................................................................................................................123 5.6 test 的属性....................................................................................................................................124 5.7 bind 元素.......................................................................................................................................125 第6 章 MyBatis 的解析和运行原理.....................................................................................................127 6.1 涉及的技术难点简介.................................................................................................................128 6.1.1 反射技术..............................................................................................................................129 6.1.2 JDK 动态代理......................................................................................................................130 6.1.3 CGLIB 动态代理.................................................................................................................133 6.2 构建SqlSessionFactory 过程...................................................................................................134 6.2.1 构建Configuration...............................................................................................................135 6.2.2 映射器的内部组成..............................................................................................................136 6.2.3 构建SqlSessionFactory........................................................................................................138 6.3 SqlSession 运行过程..................................................................................................................138 6.3.1 映射器的动态代理..............................................................................................................138 6.3.2 SqlSession 下的四大对象....................................................................................................142 6.3.3 SqlSession 运行总结............................................................................................................150 第7 章 插件.................................................................................................................................................152 7.1 插件接口.......................................................................................................................................152 7.2 插件的初始化..............................................................................................................................153 7.3 插件的代理和反射设计............................................................................................................154 7.4 常用的工具类——MetaObject................................................................................................157 7.5 插件开发过程和实例.................................................................................................................159 7.5.1 确定需要拦截的签名..........................................................................................................159 7.5.2 实现拦截方法......................................................................................................................161 7.5.3 配置和运行..........................................................................................................................162 7.5.4 插件实例..............................................................................................................................163 7.6 总结................................................................................................................................................166 第8 章 MyBatis-Spring...........................................................................................................................168 8.1 Spring 的基础知识......................................................................................................................168 8.1.1 Spring IOC 基础...................................................................................................................169 8.1.2 Spring AOP 基础..................................................................................................................171 8.1.3 Spring 事务管理...................................................................................................................173 8.1.4 Spring MVC 基础.................................................................................................................179 8.2 MyBatis-Spring 应用..................................................................................................................181 8.2.1 概述.....................................................................................................................................181 8.2.2 配置SqlSessionFactory........................................................................................................182 8.2.3 配置SqlSessionTemplate.....................................................................................................184 8.2.4 配置Mapper.........................................................................................................................188 8.2.5 配置事务..............................................................................................................................190 8.3 实例................................................................................................................................................191 8.3.1 环境准备..............................................................................................................................191 8.3.2 文件目录..............................................................................................................................193 8.3.3 Spring 配置文件...................................................................................................................194 8.3.4 MyBatis 框架相关配置........................................................................................................198 8.3.5 配置服务层..........................................................................................................................205 8.3.6 编写控制器..........................................................................................................................209 8.3.7 测试.....................................................................................................................................210 8.4 总结................................................................................................................................................210 第9 章 实用的场景...................................................................................................................................212 9.1 数据库BLOB 字段读写...........................................................................................................212 9.2 批量更新.......................................................................................................................................215 9.3 调用存储过程..............................................................................................................................217 9.3.1 存储过程in 和out 参数的使用..........................................................................................217 9.3.2 存储过程游标......................................................................................................................220 9.4 分表................................................................................................................................................225 9.5 分页................................................................................................................................................227 9.5.1 RowBounds 分页..................................................................................................................227 9.5.2 插件分页..............................................................................................................................229 9.6 上传文件到服务器.....................................................................................................................239 9.7 在映射中使用枚举.....................................................................................................................247 9.8 多对多级联..................................................................................................................................249 9.9 总结................................................................................................................................................253 附录A 数据库模型描述与级联学生关系建表语句.......................................................254
( e2 v! D9 E9 {0 C
2 k8 J- Q- m# {0 L8 h百度网盘下载地址链接(百度云):java自学网(javazx.com)深入浅出MyBatis技术原理与实战 PDF 高清 电子书 百度云.rar【密码回帖可见】7 [! b8 f- E0 v! ~; p
6 b- f4 u$ W/ b `" c% T
0 d; s4 s3 R- Q
, k" K7 i8 i5 j: S- p |