Hi Flo answers inline
2009/5/6 Flominator <flomina...@gmx.net>: > 1. Is there any way to stop NHibernate from opening too many > sessions? AR by default opens a NH session per operation. NH opens a db connection per session, but disconnects and reconnects it per operation. If you use a SessionScope, only one NH session is used for all operations within the scope and thus NH only opens one db connection. > 2. What about batching more queries into one transaction than I have > now? Put them in one TransactionScope instead of a SessionScope. Call scope.VoteCommit() or scope.VoteRollback() within the scope. > 3. Does flushing a SessionScope mean that the SessionScope is gone? No, it just forces NH to write changes to the db, instead of delaying them (all changes are then written in one batch, improving db performance). > 4. What is the relationship between sessions in NHibernate, > transactions in NHibernate, SessionScopes in AR and TransactionScopes > in AR? Plug (shameless):I posted two articles on http://mortslikeus.blogspot.com and I have prepared two more that exlain it in detail. In short: SessionScope -> one session with implicit transaction Nested SessionScopes -> evil TransactionScope -> add explicit transaction to outer SessionScope or create a new one with explicit transaction Nested TransactionScopes -> avoid, use only with inheriting outer scopes. NH cannot nest transactions within on session, thus multiple nested transactions force us to create multiple SessionScopes under the covers. > 5. I use ID fields with the AR default behavior on Firebird or MSSQL > server. That's bad. Try to use HiLo or GuidComb instead if possible. See teh following posts for explanations: http://fabiomaulo.blogspot.com/2008/12/identity-never-ending-story.html http://fabiomaulo.blogspot.com/2009/02/nh210-new-generators.html http://fabiomaulo.blogspot.com/2009/02/nh210-generators-behavior-explained.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to castle-project-users@googlegroups.com To unsubscribe from this group, send email to castle-project-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---