Chapter 10. Architectural patterns for persistence

 

This chapter covers

  • Designing the persistence layer
  • Implementing reusable Data Access Objects
  • Implementing conversations
  • Supporting Enterprise Services transactions

And so, you’ve finally arrived at the last chapter. We’ve touched on many topics along the way, and you should now feel comfortable about using NHibernate to implement persistence in your applications. You should also be roughly familiar with the breadth of features available in NHibernate and understand the flexibility they give you. We’ve also discussed layered architecture, which will help you build maintainable applications where concerns are neatly separated.

With all this knowledge, you should be able to create the domain model, map it to the database, and implement the business layer and the presentation layer. We’ve discussed domain models, but so far we haven’t addressed the persistence layer in much depth. In chapter 2, you may recall using simple function calls to load, save, and update your entities. These types of examples are great for quickly explaining concepts; but in a real-world application, you’ll benefit from something more structured and coordinated.

This chapter starts with the presentation of the Data Access Object (DAO) pattern. It’s a popular pattern that deals with the organization of the persistence layer. We’ll take this pattern and demonstrate how you can build a neat, structured persistence layer that is both generalized and reusable.

10.1. Designing the persistence layer

10.2. Implementing conversations

10.3. Using NHibernate in an Enterprise Services application

10.4. Summary