Chapter 10. iBATIS data access objects
This chapter covers
- DAO rationale
- Configuration
- A SQL Map DAO example
Applications often need to access data from multiple data sources: relational databases, file systems, directory services, web services, and other providers. Each of these data stores has a different API to access the underlying storage mechanism, along with a whole set of idiosyncrasies.
The Data Access Object (DAO) pattern is used to hide the unique implementation quirks of these APIs. It provides a simple and common API for application developers so that the consumers of the data can be free of the complexities of the data access APIs.
The iBATIS Data Access Objects subproject is a simple implementation of the core J2EE pattern of the same name.
One of the key principles of object-oriented programming is encapsulation—the separation of an implementation and its public interface. The DAO pattern is one more tool that allows you to do that in your applications. Before we go too far into the DAO pattern, let’s look at figure 10.1, to see what one looks like.
If you are thinking that figure 10.1 looks more like JDBC than a DAO, then you are only half right. It is JDBC, but the JDBC API in Java is a good example of the DAO pattern in action.