After having learned so much about NHibernate, it is time to think about some scenarios which can lead us to use NHibernate in the wrong way if we do not pay attention and can lead to a system which is unsatisfactory. One of the most obvious side effects of wrong usage or configuration of NHibernate is bad performance. Our application starts to crawl and in some situations even times out.
In this chapter we shall discuss some of the most frequent mistakes developers make when using NHibernate. We will also show how to do it right. The topics discussed are:
Avoid mappings that are too verbose or inefficient
Wrong mapping for read-only access
Never blindly rely on NHibernate but rather make informed decisions
The anti-pattern of using implicit transactions
Why not to use database generated IDs
Using LINQ to NHibernate the wrong way
How to avoid troubles with lazy loading
Considering using a read and a write model in complex domains
Phantom updates and what...