about this book

iBATIS is all about simplicity. There was a time when I said, “If I ever need to write a book about iBATIS, I’m doing something wrong.” And here I am, writing a book about iBATIS. It turns out that no matter how simple something is, a book is sometimes the best way to learn about it. There’s a lot of speculation these days that books might be replaced by e-books or by a jack in the back of our head that uploads information in a matter of seconds. Neither of those sounds terribly comfortable. I like books because they’re portable and flexible. I can write on them, bend the pages, crack the spine. Nothing would make me happier than to see a well-worn copy of iBATIS in Action littering the floor of a busy developer’s office. Success.

Clinton Begin

What you should know

We hope that this book will keep the theme of iBATIS simplicity, but sometimes abstract concepts require more words. Certain chapters may be long and drawn out if you’re not concerned with theory. Other chapters will be quick and to the point as if to say, “Here’s how it works, and here’s an example—now get to it.”

The book assumes some knowledge. We expect you to know Java. We won’t pull any punches here. This should not be the first or second Java book you’ve read. You should have felt the pain of using JDBC and possibly even experienced some of the pitfalls of O/RM.

We also expect you to know SQL. iBATIS is a SQL-centric framework. We don’t attempt to hide the SQL; it’s not generated and you’re in full control of it. So you should have some SQL development experience under your belt.

Finally, you should be familiar with XML. As much as we wish there were a better solution, XML just makes sense for iBATIS development. It supports authoring of large blocks of text (i.e., SQL) much better than Java (which has no multiline string support), and it supports rich markup, allowing for the creation of a custom configuration syntax. Future versions of iBATIS may have other means of configuration and development, but for now, it’s XML and you need to be familiar with it.

Who should read this book?

The developer community is our primary target audience. We fully expect that you will skip this section, skim through most of the early chapters on higher-level abstract topics, and move on to the first section where you see code. We expect you to read through the book while coding something completely unrelated with South Park on the television in the background.

Recovering O/RM users will enjoy iBATIS and this book. O/RM has a history of being a silver bullet solution that simply does not deliver. A lot of projects have started with O/RM but were finished with SQL. iBATIS focuses on solving existing problems without introducing new ones. We’re not against using O/RM, but chances are good that you’ve hit a snag or two when trying to use an O/RM solution where a different approach would have been more efficient.

Architects will enjoy the higher-level section, which discusses the unique approach that iBATIS takes. There is a lot of hype about O/RM, and architects need to be informed that O/RM is not the only way. They need to learn to draw a new box with new lines to that old box that sits beside the O/RM box and connects it with a line to some other box—all the while ensuring that the Law of Demeter is never broken, of course!

Data modelers will probably not want to read this book, but we hope that someone will encourage them to. iBATIS was a product partially created in frustration with the database designs that came from people who refused to follow the rules of proper database normalization (and judicious denormalization). Data modelers will be familiar with the challenges of most legacy and ERP systems that have been built by some of the largest software companies in the world. Others who should read this book include managers/executives, database administrators, quality assurance/testers, and analysts. Of course, anyone is more than welcome to buy it, if only for the cool cover.

Roadmap

Part 1 of this book offers a high-level introduction of iBATIS. It includes chapters 1 and 2, which describe the iBATIS philosophy and what iBATIS is. These chapters provide background for people interested in the foundations of iBATIS. If you’re looking for the more practical application of iBATIS and want to get right down to work, skip to part 2.

Chapters 3 through 7 comprise part 2 of the book, which takes you through the basic applications of iBATIS. These chapters are essential reading if you intend to develop with iBATIS. Chapter 3 walks you through installation of the framework. Chapters 4, 5, and 6 teach you how to work with various kinds of statements. Chapter 7 wraps up part 2 with a detailed discussion of transaction support in iBATIS, which will help ensure that transactions are used properly in your application.

Part 3 begins our discussion of advanced iBATIS topics. Chapter 8 examines Dynamic SQL, which is one of the key innovations of iBATIS and essential for introducing complex query capabilities into your application. Chapter 9 continues the advanced topics with a discussion of caching data. As it turns out, caching is one of the more complex challenges with a SQL mapping framework, and you’ll want to read this chapter to ensure that you understand how it’s implemented. iBATIS is actually two frameworks in one: the SQL Mapper and the DAO framework. The DAO framework is completely independent, but it’s always been part of iBATIS, so it’s important to discuss it here. Chapters 10 and 11 discuss the DAO framework in detail. iBATIS is also a flexible framework. Wherever possible, pluggable interfaces have been used so you can include your own custom behavior into the framework. Chapter 12 investigates how you can extend iBATIS to do just that.

Part 4 places iBATIS in the real world. Chapter 13 examines a number of best practices for working with iBATIS. We wrap up the book in chapter 14 with a comprehensive web application called JGameStore. The full source of the JGameStore application is available from the iBATIS homepage and Manning’s website. Like all of the source code in this book, JGameStore is licensed under the Apache License 2.0, so you’re free to download it and use it as you like.

Source code conventions and downloads

Source code in listings or code terms in text appear in a fixed-width font like this. Code annotations accompany many of the listings, highlighting important concepts. In some cases, numbered cueballs link to additional explanations that follow the listing.

You can download the source code for all of the examples in the book and for the JGameStore application from the publisher’s website at www.manning.com/begin.

Author Online

Purchase of iBATIS in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/begin. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum. It also provides links to the source code for the examples in the book, errata, and other downloads.

Manning’s commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.