買這商品的人也買了...
-
$580$458 -
$454Netty 權威指南, 2/e
-
$680$530 -
$301Zabbix 企業級分佈式監控系統
-
$360$284 -
$420$328 -
$680$537 -
$454Spring 實戰, 4/e (Spring in Action, 4/e)
-
$474$450 -
$454JavaEE 開發的顛覆者: Spring Boot實戰
-
$500Spring 入門經典 (Beginning Spring)
-
$237JUnit 實戰, 2/e (JUnit in Action, 2/e)
-
$420$332 -
$301R語言與數據挖掘
-
$680$537 -
$419$398 -
$320$250 -
$449Hibernate 實戰, 2/e
-
$653高可用 MySQL, 2/e (MySQL High Availability: Tools for Building Robust Data Centers, 2/e)
-
$174Spring + MyBatis 企業應用實戰
-
$301區塊鏈開發指南
-
$403MyBatis 技術內幕
-
$750$638 -
$760Java 核心技術 捲II : 高級特性, 11/e (Core Java Volume II -- Advanced Features, 11/e)
-
$520$406
相關主題
商品描述
<內容介紹>
當前已經是移動因特網時代,Java持久框架Hibernate沒有辦法適應高性能,靈活,大數據,可優化等要求,這時MyBatis就進入了我們的視野,隨著移動因特網應用的持續發酵,Spring+MyBatis的應用已在Java因特網平臺上得到大量的使用,單單在51job招聘網站中MyBatis在全國也有近萬個崗位的需求,加上未在51job發布的企業,可見需求相當大,而在當今市場上卻沒有任何一本介紹MyBatis的書籍,為了填補這一空白本書主要介紹了Java MyBatis技術。本書詳細介紹了MyBatis的基礎組成、配置、映射器、動態SQL,教會讀者正確使用MyBatis,書中包含大量的實例,使讀者可以參考。接著介紹了MyBatis的運行原理和插件開發並配有一個完整的插件例子。為了增加實用性,作者還介紹了MyBatis-Spring項目,使得讀者能夠學習到如何把MyBatis整合到Spring項目中,最後作者還將講解一些常用實例,比如Blob字段、文件上傳、批量、動態表名等實用場景,讓讀者能夠參考和註意一些細節的問題。本書從基礎講到底層,註重實戰,原理,照顧到初中高三類讀者,可以作為MyBatis的學習教程和參考技術叢書。
<章節目錄>
第1 章 MyBatis 簡介................................................................................................................................ 1
1.1 傳統的JDBC 編程...................................................................................................................... 1
1.2 ORM 模型..................................................................................................................................... 4
1.3 Hibernate.................................................................................................................................. 4
1.4 MyBatis ................................................................................................................................... 9
1.5 什麽時候用MyBatis..................................................................................................................12
第2 章 MyBaits 入門.......................................................................................................................13
2.1 開發環境準備.............................................................................................................................13
2.1.1 下載MyBatis .......................................................................................................................13
2.1.2 搭建開發環境......................................................................................................................14
2.2 MyBatis 的基本構成..................................................................................................................15
2.2.1 構建SqlSessionFactory........................................................................................................15
2.2.2 創建SqlSession...................................................................................................................19
2.2.3 映射器.................................................................................................................................21
2.3 生命周期.......................................................................................................................................26
2.3.1 SqlSessionFactoryBuilder.....................................................................................................27
2.3.2 SqlSessionFactory................................................................................................................27
2.3.3 SqlSession............................................................................................................................27
2.3.4 Mapper.................................................................................................................................28
2.4 實例.........................................................................................................................................29
第3 章 配置.......................................................................................................................................37
3.1 properties 元素.............................................................................................................................38
3.1.1 property 子元素....................................................................................................................38
3.1.2 properties 配置文件.............................................................................................................39
3.1.3 程序參數傳遞......................................................................................................................39
3.1.4 優先級.................................................................................................................................40
3.2 設置.......................................................................................................................................41
3.3 別名......................................................................................................................................44
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
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 映射器的內部組成............................................................................................................135
6.2.3 構建SqlSessionFactory......................................................................................................137
6.3 SqlSession 運行過程................................................................................................................138
6.3.1 映射器的動態代理............................................................................................................138
6.3.2 SqlSession 下的四大對象..................................................................................................141
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