Chapter 2. Data Access Objects

2.1. Data Access Objects

The iBATIS.NET Data Access Objects API can be used to help hide persistence layer implementation details from the rest of your application by allowing dynamic and pluggable DAO components to be easily swapped in and out. For example, you could have two implementations of a particular DAO, one that uses the iBATIS.NET DataMapper framework and another that uses the NHibernate framework, to persist objects to the database. Another example would be a DAO that provides caching services for another DAO. Depending on the situation (e.g. limited database performance vs. limited memory), either the cache DAO could be plugged in or the standard un-cached DAO could be used. These examples show the convenience, and more importantly, the safety that the DAO pattern provides. The DAO pattern protects your application from possibly being tied to a particular persistence approach. In the event that your current solution becomes unsuitable (or even unavailable), you can simply create new DAO implementations to support a new solution without having to modify any code in the other layers of your application.

[Note]Note

The iBATIS.NET DAO Framework and DataMapper Framework are completely separate and are not dependent on each other in any way. Please feel free to use either one separately, or both together.