NHibernate Desktop App : should it use multiple sessions?
Should a NHibernate desktop app use a SessionFactory and multiple sessions ? Does the One session per transaction rule apply only to web applications ?
Yes, an NHibernate desktop application should typically use multiple sessions.
In a two-tier scenario, you'll use a session per logical "session of interaction," such as a given "view" or "screen." Here you can maintain the session longer than you could in a web application, and reap the full benefit of lazy-loading, but at some point you want the user to "save" or "cancel" and move on to something else, and this is often a good place to end the session.
Using a single session throughout the application can cause a lot of stuff to be cached, and the client-side data may become stale or you could run into concurrency problems.
Furthermore, once a session encounters an exception, it is no longer valid and you'll have to abandon/reset whatever you were doing. If that is one form, it isn't a big deal, but if you have lots of objects throughout your application referencing the same session, they'll all be in a compromised state.