1. Your assumption is correct. Commit calls Flush unless you set FlushMode.Never, and it's usually best to leave it to NHibernate.
2. As long as you use transactions and respect the exception semantics (i.e. stop using the session as soon as you get an exception), it is safe. Whether it is appropriate regarding Unit Of Work... well, that depends a lot on your logic. 3. One SessionFactory can serve everyone. It's safe to create all the sessions you want, from different requests, threads, etc. Diego On Sat, Jan 2, 2010 at 23:20, Franky <[email protected]> wrote: > Getting started with NH n hoping someone can give me a bit of info: > > One thing i have found, and am a bit unsure of is: > 1. Do i need to flush() before commit() and close()? > i have seen many examples without the flush() statement and many with. > i was under the impression that commit calls it for you (default > flushmode) basically if using transactions – which i think would be a > good idea. > > 2. If using session per request, is it safe to do separate, unrelated > tasks off the same session? Eg. Save some info, then run a Get or Load > to return a list of results all from the one session? Or do I have to > clear the session first? I'm thinking that session per request sort of > misses the one unit of work each session principle. Or am I wrong? > > 3. Maybe a silly question, but iv never really looked into singleton > pattern... if I implement sessionfactory using a singleton class, does > this mean it will create sessionfactory on first call, and then make > it available for the life of the browser, so each user will have their > own sessionfactory created? Or does the 1 sessionfactory serve all > users of the website app, once it is created? > > Just trying to clear a few of my thoughts up... > > Thanks in advance, I'm looking forward to working with the framework! > > Franky > > -- > > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
