database - NHibernate Desktop App : should it use multiple sessions? -
should nhibernate desktop app use sessionfactory , multiple sessions ? one session per transaction rule apply web applications ?
regards, madseb
yes, nhibernate desktop application should typically use multiple sessions.
in two-tier scenario, you'll use session per logical "session of interaction," such given "view" or "screen." here can maintain session longer in web application, , reap full benefit of lazy-loading, @ point want user "save" or "cancel" , move on else, , place end session.
using single session throughout application can cause lot of stuff cached, , client-side data may become stale or run concurrency problems.
furthermore, once session encounters exception, no longer valid , you'll have abandon/reset whatever doing. if 1 form, isn't big deal, if have lots of objects throughout application referencing same session, they'll in compromised state.
Comments
Post a Comment