Hello
I want to create my first nhibernate projet.
It will be a migration from a winform project associated with an old dataacess with no strong orm mapping.
The project is quite large so I’d like to have a good architecture from the beginning.
I will have some layer :
- Repository : Create the session from nhibernate
- Model : The bean object, basically it consists of getter / setter properties with the same name in the database
But I’ll need some advices, how will you handle the operations ?
If I want to create an item should I access directly to nhibernate from the code ? Or should I create a business logic layer ?
Basically I found that simple architecture for the business layer.
http://www.codeproject.com/KB/architecture/NHibernateArchitecture.aspx
What is your feeling ?
Another question, it is a program with strong validation (glasses domain), where should be the validation ? in the winform project or in a business layer ?
It’s hard to say and give useful advices without seeing the project and its actual problems. Is it client-server architecture for instance? What do you mean by “quite large”? There are too many different projects to have rules which fit all.
Generally:
The most common mistake I see when starting with NH is that people don’t understand persistence ignorance. This means that you should write your business logic without accessing the database or NH. Changes are made on the entities, they are not “temporarily” until they get explicitly applied to the database, they get implicitly stored when the transaction gets committed. This has a huge impact to the code. In many cases, there is no “Store” or “Update” or whatever.