详细说明: 1 The iBATIS philosophy 3 1.1 A hybrid solution: combining the best of the best 4 Exploring the roots of iBATIS 5 Understanding the iBATIS advantage 10 1.2 Where iBATIS fits 14 The business object model 15 ■ The presentation layer 15 The business logic layer 17 ■ The persistence layer 18 The relational database 19 1.3 Working with different database types 22 Application databases 22 ■ Enterprise databases 23 Proprietary databases 25 ■ Legacy databases 25 x CONTENTS 1.4 How iBATIS handles common database challenges 26 Ownership a nd control 26 ■ Access by multiple disparate systems 27 ■ Complex keys and relationships 28 ■ Denormalized or overnormalized models 29 ■ Skinny data models 30 1.5 Summary 32 2 What is iBATIS? 33 2.1 Mapping SQL 35 2.2 How it works 37 iBATIS for small, simple systems 38 iBATIS for large, enterprise systems 39 2.3 Why use iBATIS? 40 Simplicity 40 ■ Productivity 41 ■ Performance 41 Separation of concerns 42 ■ Division of labor 42 ■ Portability: Java, .NET, and others 42 ■ Open source and honesty 43 2.4 When not to use iBATIS 43 When you have full control…forever 43 ■ When your application requires fully dynamic SQL 44 ■ When you’re not using a relational database 44 ■ When it simply does not work 45 2.5 iBATIS in five minutes 45 Setting up the database 46 ■ Writing the code 46 ■ Configuring iBATIS (a preview) 47 ■ Building the application 49 Running the application 49 2.6 The future: where is iBATIS going? 50 Apache Software Foundation 50 ■ Simpler, smaller, with fewer dependencies 51 ■ More extensions and plug-ins 51 Additional platforms and languages 51 2.7 Summary 52 PART 2 IBATIS BASICS ................................................55 3 Installing and configuring iBATIS 57 3.1 Getting an iBATIS distribution 58 Binary distribution 59 ■ Building from source 59 3.2 Distribution contents 62 CONTENTS xi 3.3 Dependencies 62 Bytecode enhancement for lazy loading 63 ■ Jakarta Commons Database Connection Pool 63 ■ Distributed caching 64 3.4 Adding iBATIS to your application 64 Using iBATIS with a stand-alone application 64 Using iBATIS with a web application 65 3.5 iBATIS and JDBC 65 Releasing JDBC resources 66 ■ SQL injection 66 Reducing the complexity 67 3.6 iBATIS configuration continued 68 The SQL Map configuration file 69 ■ The element 70 The element 71 ■ The elements 73 ■ The element 75 ■ The element 77 ■ The element 78 3.7 Summary 78 4 Working with mapped statements 80 4.1 Starting with the basics 81 Creating JavaBeans 81 ■ The SqlMap API 85 Mapped statement types 86 4.2 Using