Clinton Begin, Brandon Goodin, Larry Meadors9781932394825, 1-932394-82-6
Table of contents :
iBATIS in Action……Page 1
contents……Page 10
preface……Page 18
acknowledgments……Page 20
Introduction……Page 32
The iBATIS philosophy……Page 34
1.1 A hybrid solution: combining the best of the best……Page 35
1.1.1 Exploring the roots of iBATIS……Page 36
1.1.2 Understanding the iBATIS advantage……Page 41
1.2 Where iBATIS fits……Page 45
1.2.2 The presentation layer……Page 46
1.2.3 The business logic layer……Page 48
1.2.4 The persistence layer……Page 49
1.2.5 The relational database……Page 50
1.3.1 Application databases……Page 53
1.3.2 Enterprise databases……Page 54
1.3.4 Legacy databases……Page 56
1.4.1 Ownership and control……Page 57
1.4.2 Access by multiple disparate systems……Page 58
1.4.3 Complex keys and relationships……Page 59
1.4.4 Denormalized or overnormalized models……Page 60
1.4.5 Skinny data models……Page 61
1.5 Summary……Page 63
What is iBATIS?……Page 64
2.1 Mapping SQL……Page 66
2.2 How it works……Page 68
2.2.1 iBATIS for small, simple systems……Page 69
2.2.2 iBATIS for large, enterprise systems……Page 70
2.3.1 Simplicity……Page 71
2.3.3 Performance……Page 72
2.3.6 Portability: Java, .NET, and others……Page 73
2.4.1 When you have full control…forever……Page 74
2.4.3 When you’re not using a relational database……Page 75
2.5 iBATIS in five minutes……Page 76
2.5.2 Writing the code……Page 77
2.5.3 Configuring iBATIS (a preview)……Page 78
2.5.5 Running the application……Page 80
2.6.1 Apache Software Foundation……Page 81
2.6.4 Additional platforms and languages……Page 82
2.7 Summary……Page 83
iBATIS basics……Page 86
Installing and configuring iBATIS……Page 88
3.1 Getting an iBATIS distribution……Page 89
3.1.2 Building from source……Page 90
3.3 Dependencies……Page 93
3.3.2 Jakarta Commons Database Connection Pool……Page 94
3.4.1 Using iBATIS with a stand-alone application……Page 95
3.5 iBATIS and JDBC……Page 96
3.5.2 SQL injection……Page 97
3.5.3 Reducing the complexity……Page 98
3.6 iBATIS configuration continued……Page 99
3.6.1 The SQL Map configuration file……Page 100
3.6.2 The element……Page 101
3.6.3 The element……Page 102
3.6.4 The elements……Page 104
3.6.5 The element……Page 106
3.6.6 The element……Page 108
3.7 Summary……Page 109
Working with mapped statements……Page 111
4.1.1 Creating JavaBeans……Page 112
4.1.2 The SqlMap API……Page 116
4.1.3 Mapped statement types……Page 117
4.2.1 Using inline parameters with the # placeholders……Page 120
4.2.2 Using inline parameters with the $ placeholders……Page 122
4.2.3 A quick look at SQL injection……Page 123
4.2.4 Automatic result maps……Page 124
4.3.1 External parameter maps……Page 126
4.3.2 Inline parameter mapping revisited……Page 128
4.3.4 JavaBean and Map parameters……Page 130
4.4 Using inline and explicit result maps……Page 131
4.4.1 Primitive results……Page 132
4.4.2 JavaBean and Map results……Page 133
4.5 Summary……Page 134
Executing nonquery statements……Page 136
5.1.1 The SqlMap API for nonquery SQL statements……Page 137
5.1.2 Nonquery mapped statements……Page 138
5.2.1 Using inline parameter mapping……Page 139
5.2.2 Using an external parameter map……Page 140
5.2.3 Autogenerated keys……Page 141
5.3 Updating and deleting data……Page 144
5.3.2 Updating or deleting child records……Page 145
5.4 Running batch updates……Page 146
5.5.1 Considering the pros and cons……Page 148
5.5.2 IN, OUT, and INOUT parameters……Page 150
5.6 Summary……Page 152
Using advanced query techniques……Page 153
6.1.1 XML parameters……Page 154
6.1.2 XML results……Page 156
6.2.1 Complex collections……Page 159
6.2.2 Lazy loading……Page 162
6.2.3 Avoiding the N+1 Selects problem……Page 163
6.3 Inheritance……Page 165
6.3.1 Mapping Inheritance……Page 167
6.4.1 Using the statement type and DDL……Page 168
6.4.2 Processing extremely large data sets……Page 169
6.5 Summary……Page 175
Transactions……Page 176
7.1.1 A simple banking example……Page 177
7.1.2 Understanding transaction properties……Page 179
7.2 Automatic transactions……Page 182
7.3 Local transactions……Page 183
7.4 Global transactions……Page 184
7.4.1 Using active or passive transactions……Page 185
7.4.2 Starting, committing, and ending the transaction……Page 186
7.5 Custom transactions……Page 187
7.6 Demarcating transactions……Page 189
7.6.1 Demarcating transactions at the presentation layer……Page 190
7.6.3 Demarcating transactions at the business logic layer……Page 191
7.7 Summary……Page 192
Using Dynamic SQL……Page 194
8.1 Dealing with Dynamic WHERE clause criteria……Page 195
8.2 Getting familiar with the dynamic tags……Page 197
8.2.1 The tag……Page 199
8.2.2 Binary tags……Page 200
8.2.3 Unary tags……Page 202
8.2.4 Parameter tags……Page 203
8.2.5 The tag……Page 204
8.3 A complete simple example……Page 206
8.3.3 Writing the SQL in static format……Page 207
8.3.4 Applying Dynamic SQL tags to static SQL……Page 208
8.4.1 Defining the resulting data……Page 209
8.4.2 Defining the required input……Page 210
8.4.3 Writing the SQL in static format……Page 211
8.4.4 Applying Dynamic SQL tags to static SQL……Page 212
8.5 Alternative approaches to Dynamic SQL……Page 214
8.5.1 Using Java code……Page 215
8.5.2 Using stored procedures……Page 218
8.5.3 Comparing to iBATIS……Page 220
8.6.1 Simplified conditional tags……Page 221
8.7 Summary……Page 222
iBATIS in the real world……Page 224
Improving performance with caching……Page 226
9.1 A simple iBATIS caching example……Page 227
9.2 iBATIS’s caching philosophy……Page 228
9.3.1 Type……Page 229
9.3.3 The serialize attribute……Page 230
9.3.4 Combining readOnly and serialize……Page 231
9.4.1 Cache flushing……Page 232
9.5 Cache model types……Page 235
9.5.1 MEMORY……Page 236
9.5.2 LRU……Page 237
9.5.3 FIFO……Page 238
9.6 Determining a caching strategy……Page 239
9.6.1 Caching read-only, long-term data……Page 240
9.6.2 Caching read-write data……Page 242
9.6.3 Caching aging static data……Page 244
9.7 Summary……Page 247
iBATIS data access objects……Page 248
10.1 Hiding implementation details……Page 249
10.1.1 Why the separation?……Page 250
10.1.2 A simple example……Page 251
10.2.2 The element……Page 254
10.2.3 The element……Page 255
10.2.4 The DAO elements……Page 260
10.3.1 Multiple servers……Page 261
10.3.2 Multiple database dialects……Page 262
10.3.3 Runtime configuration changes……Page 263
10.4 A SQL Map DAO implementation example……Page 264
10.4.1 Configuring the DAO in iBATIS……Page 265
10.4.3 Defining the transaction manager……Page 266
10.4.4 Loading the maps……Page 267
10.4.5 Coding the DAO implementation……Page 270
10.5 Summary……Page 272
Doing more with DAO……Page 273
11.1.1 A Hibernate DAO implementation……Page 274
11.1.2 A JDBC DAO implementation……Page 279
11.2.1 Example: using a DAO with LDAP……Page 284
11.2.2 Example: using a DAO with a web service……Page 289
11.3.1 Writing the code……Page 291
11.4 Creating your own DAO layer……Page 293
11.4.2 Decoupling and creating a factory……Page 294
11.5 Summary……Page 297
Extending iBATIS……Page 298
12.1 Understanding pluggable component design……Page 299
12.2 Working with custom type handlers……Page 300
12.2.1 Implementing a custom type handler……Page 301
12.2.2 Creating a TypeHandlerCallback……Page 302
12.2.3 Registering a TypeHandlerCallback for use……Page 306
12.3 Working with a CacheController……Page 307
12.3.2 Putting, getting, and flushing a CacheController……Page 308
12.3.3 Registering a CacheController for use……Page 309
12.4 Configuring an unsupported DataSource……Page 310
12.5 Customizing transaction management……Page 311
12.5.1 Understanding the TransactionConfig interface……Page 312
12.5.2 Understanding the Transaction interface……Page 313
12.6 Summary……Page 314
iBATIS recipes……Page 316
iBATIS best practices……Page 318
13.1.1 Unit-testing the mapping layer……Page 319
13.1.2 Unit-testing data access objects……Page 322
13.1.3 Unit-testing DAO consumer layers……Page 324
13.2.1 Keep it on the classpath……Page 326
13.2.2 Keep your files together……Page 328
13.3.2 Naming parameter maps……Page 329
13.3.4 XML files……Page 330
13.4.2 Maps……Page 331
13.5 Summary……Page 332
Putting it all together……Page 334
14.1.2 Catalog……Page 335
14.2.2 Service……Page 336
14.3 Tweaking Struts: the BeanAction……Page 337
14.3.3 ActionContext……Page 338
14.4.1 src……Page 339
14.4.3 web……Page 340
14.4.6 lib……Page 341
14.5 Configuring the web.xml……Page 342
14.6.1 The first step……Page 343
14.6.2 Utilizing a presentation bean……Page 346
14.7 Writing your service……Page 351
14.7.1 Configuring dao.xml……Page 352
14.7.2 Transaction demarcation……Page 353
14.8 Writing the DAO……Page 354
14.8.1 SQLMap configuration……Page 355
14.8.2 SQLMap……Page 356
14.8.3 Interface and implementation……Page 357
14.9 Summary……Page 359
appendix: iBATIS.NET Quick Start……Page 360
Why should .NET developers care about iBATIS.NET?……Page 361
A.2 Working with iBATIS.NET……Page 362
The XML configuration file……Page 363
SQL mapping files……Page 365
A.3 Where to go for more information……Page 367
index……Page 368
Reviews
There are no reviews yet.