Problems encountered while working with nhibernate
I am currently working on a project and using nhibernate as OR开发者_开发问答M. The project is working fine in the development envoirnment. Before we go into production I would like to know from the expericence of the community that logical errors were encountered after they went live that were not caught in development. In short I want to know a check list of things one need to do before we go live.
I don't really have a checklist but one of the things that caught us the first time we used NHibernate was that fact that we didn't test it under realistic "load" in our development environment.
When we went to production we were getting unexpected timeouts. It turned out that our ICriteria queries were very inefficient and we had to tweak them accordingly.
One other thing that initially caught us was NHibernates dll dependencies. It depends on Log4net, Iesi.Collections and a few more - ensure your deployment strategy covers this.
This is an old one, but here are a few..
Mappings - if you have a legacy database with other than straightforward mappings, use NHibernate Profiler to check what is actually being queried for. Sometimes, a fairly innocent Load on an object can result in multiple joins.
Concurrency - make sure to read up on how transactions are handled. A unit of work (ISession) and how it works is important to avoid weird bugs where inconsistent data is read.
Concurrency - make sure you understand NHibernates concurrency models. It can severely affect your application and throw StaleObjectExceptions on you when concurrent writes are happening. See this for a starter: NHibernate Concurrency
精彩评论