tbroyer
03-28-2007, 02:54 PM
Hi,
I'm having an InvalidDataAccessApiUsageException ("Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition") when I try to save or update an entity.
I'm using an OpenSessionInViewModule in an ASP.NET 2.0 application.
If I use HibernateTemplate.Execute and call SaveOrUpdate on the ISession, no exception is thrown but as the session is never flushed (except if I explicitly call ISession.Flush) nothing is stored in the database.
I know the OpenSessionInViewModule is setting the session's FlushMode to FlushMode.Never, and comments within the code say I could create a derived class and override this behavior.
I find it a bit odd, so I'm wondering what's the expected "coding style":
should I use HibernateTemplate.Execute and call SaveOrUpdate on the ISession avec turning it into FlushMode.Auto (rather than calling HibernateTemplate.SaveOrUpdate)?
should I use HibernateTemplate.Execute an explicitly call ISession.Flush() after the call to ISession.SaveOrUpdate?
should I use a derived OSIV overriding the default FlushMode?Thanks in advance
I'm having an InvalidDataAccessApiUsageException ("Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition") when I try to save or update an entity.
I'm using an OpenSessionInViewModule in an ASP.NET 2.0 application.
If I use HibernateTemplate.Execute and call SaveOrUpdate on the ISession, no exception is thrown but as the session is never flushed (except if I explicitly call ISession.Flush) nothing is stored in the database.
I know the OpenSessionInViewModule is setting the session's FlushMode to FlushMode.Never, and comments within the code say I could create a derived class and override this behavior.
I find it a bit odd, so I'm wondering what's the expected "coding style":
should I use HibernateTemplate.Execute and call SaveOrUpdate on the ISession avec turning it into FlushMode.Auto (rather than calling HibernateTemplate.SaveOrUpdate)?
should I use HibernateTemplate.Execute an explicitly call ISession.Flush() after the call to ISession.SaveOrUpdate?
should I use a derived OSIV overriding the default FlushMode?Thanks in advance