Hi folks,
I was wonder if you'd share the set of practices/policies you have implemented in your project that work for you. I'm talking about whole set, not only "one session per application/request/whatever".
I'm fairly new to NHibernate but this rules work for me so far on an ASP.NET project:
0) Single assembly for the whole domain model.
1) Session-per-request, the session is for reads only (FlushMode=Never), with separate new session on the same connection for each transaction.
2) Mapped entities are ignorant of the persistence framework.
3) Persistence and queries are performed by separate "doer" classes (typically some sort of manager implementing FindXByID(), SaveX() and the like).
4) Save parent, cascade to children.
5) Evict-SaveOrUpdate-Lock/Refresh
6) Map relationship to reference table as as IDs instead of entity. (There is hardly ever a need to dereference those)
7) All entities requiring an audit trail implement a single interface and an interceptor checks for the interface and creates the actual trail.
8) All reference entities implement a method (interface) to return a simple key-value object that could be used to bind to UI elements (such as dropdowns).
9) Unit test.
Any takers?
TIA,
E.
|