Patterns

posts concerning one ore more design patterns
First and Second Level caching in NHibernate

I'll try to dive deep into the caching of NHibernate in this article. This post has been inspired by the talk given by Oren Eini (aka Ayende) at the Kaizen Conference in Austin TX. Caching is a topic that is IMHO only superficially described so far especially regarding the second level cache. Most of the time one finds a lot of information about how to configure a specific cache provider for usage but the real usage (who and when) is not really described. I hope to be able to provide some of the missing pieces with this post....

posted @ Sunday, November 09, 2008 5:57 AM | Feedback (963)

The Repository Pattern

Introduction When accessing data from a data source we have several well documented possibilities. Martin Fowler e.g. describes several of them in his PoEAA book. Table data gateway Row data gateway Active record Data mapper When applying DDD (domain driven design) we often use the so called Repository Pattern to access the data needed by the domain model. What is a Repository Martin Fowler writes: "A Repository mediates between the domain and data mapping layers,...

posted @ Wednesday, October 08, 2008 1:42 AM | Feedback (1446)

NHibernate and the Unit of Work pattern (Part 3)

Introduction In the previous two posts which you can find here and here I introduced the Unit of Work pattern and developed a working version based on NHibernate. One weak point of the shown implementation is that it is strictly non thread safe. In NHibernate the session object takes the role of the Unit of Work container. The session object is not thread safe! That is a session instance may not be accessed from different threads. If your application is running on multiple threads (typically an application running on the server) then you have to open a new session...

posted @ Saturday, April 26, 2008 7:04 AM | Feedback (569)

NHibernate and the Unit of Work Pattern (Part 2)

In the first part of this series I have started to implement the Unit of Work pattern. In this post I'll finish this implementation (for non-thread safe version) and in a third post I'll discuss how to make this implementation thread safe. Design and Implementation The Unit Of Work Factory The creation of a unit of work instance is a complex process and as such is a good candidate for a factory. Since a UoW (Unit of Work) is basically a wrapper around a NHibernate session object I'll need to open such a session whenever...

posted @ Sunday, April 13, 2008 10:16 PM | Feedback (524)