I've grown to prefer FlushMode.Commit, and would like to configure it as the default FlushMode for sessions that the ISessionFactory creates. I can't find a built-in way to do this. The options I see are:
Just set the FlushMode property after calling OpenSession. But I can't always do this because some of my code uses ThreadLocalSessionContext, which may call OpenSession for me.
Set the FlushMode on the ISession every time I touch it.
Create an ISessionFactoryImlementor wrapper which will set the appropriate FlushMode for me.
So I do have options, and the last option, writing a session factory wrapper, is definitely viable and non-intrusive. It just really feels like this should be a configurable option baked into NHibernate, just like DefaultEntityMode.
I think the ideal solution would be a new Configuration property - something like:
... which would affect the initial FlushMode of any sessions created by that session factory.
Environment
None
Activity
Show:
Alex Zaytsev
May 1, 2017 at 3:40 AM
Closing issues resolved in 4.1.0
Alex Zaytsev
February 22, 2015 at 10:45 PM
Merged to master @ 5684575c9a6c2b0e4ec91e78ab6d2f4682a77f60
I've grown to prefer
FlushMode.Commit
, and would like to configure it as the defaultFlushMode
for sessions that theISessionFactory
creates. I can't find a built-in way to do this. The options I see are:Just set the
FlushMode
property after callingOpenSession
. But I can't always do this because some of my code usesThreadLocalSessionContext
, which may callOpenSession
for me.Set the
FlushMode
on theISession
every time I touch it.Create an
ISessionFactoryImlementor
wrapper which will set the appropriateFlushMode
for me.So I do have options, and the last option, writing a session factory wrapper, is definitely viable and non-intrusive. It just really feels like this should be a configurable option baked into NHibernate, just like
DefaultEntityMode
.I think the ideal solution would be a new
Configuration
property - something like:... which would affect the initial
FlushMode
of any sessions created by that session factory.