Is it possible to confine NHibernate to the data access layer? I'm learning NHibernate, and I am finding a lot of code that pollutes business logic with NHibernate code. Often, business logic gets a session from a session provider and passes it to a repository, which uses the session to get domain objects from the database. The business logic ends up managing the session lifecycle.
I'd like to isolate the session to the data access layer. In other words, I'd like my business logic, as well as my domain, to be totally ignorant of NHibernate. For example, I'd like to be able to test the data access layer without my unit test project holding a refwerence to NHibernate.
Here are my questions: Is that practical? Are there any good examples of how to do it? Where?
Thanks for your help.
David Veeneman
Foresight Systems
|