Chapter 13. iBATIS best practices

 

This chapter covers

  • Unit testing
  • Configuration management
  • Naming
  • Data structures

iBATIS is all about best practices—it is largely the reason iBATIS was created. For starters, iBATIS helps you maintain separation of concerns between your application and the persistence layer. It also helps you avoid mixing Java and SQL and ending up with a mess of twisted code. iBATIS lets you separate the design of your object-oriented domain model from your relational data model. This chapter discusses a number of best practices that will help you get the most out of iBATIS.

13.1. Unit testing with iBATIS

Unit testing has become a very important part of modern software development methodologies. Even if you don’t subscribe to the benefits of extreme programming or other agile methods, unit testing should be a cornerstone practice in your software development life cycle.

Conceptually, the persistence tier is separated into three layers, and iBATIS makes it easy to unit-test those layers, as illustrated in figure 13.1.

Figure 13.1. These are the typical layers immediately involved with persistence (nonpersistence-related layers are not shown in this diagram).

iBATIS facilitates testing these layers in at least three ways:

13.2. Managing iBATIS configuration files

13.3. Naming conventions

13.4. Beans, maps, or XML?

13.5. Summary