The NHibernate session architecture
We looked at configuration, sessionFactory
, and session
among other things in the previous section. These three components encapsulate most of the functionality offered by NH. I do not mean this in literal sense. If you look at NHibernate source code, you will see that a lot of NHibernate features are implemented independently of these components. But these components are gateways into using these features.
Following diagram shows how these three relate to each other:
The preceding diagram represents components of a real life application. Layers above Data Access Layer are represented in an abstract way, combining everything into one layer. In Data Access Layer, you have got Configuration as one of the components. Configuration knows about mappings available in Data Access Layer. It also knows about lot of other details that are used either during warming up NHibernate or interacting with Database.
As we have seen earlier, calling the BuildSessionFactory...