This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

InvalidDataAccessApiUsageException when switching to 1.1Page Title Module

We use declarative transaction support using
@@org.springframework.transaction.interceptor.Defa ultTransactionAttribute() on service objects (readOnly=false).

We also use the OpenSessionInViewInterceptor. Before 1.1 everything worked fine. Now because the FlushMode of the OpenSessionInViewInterceptor is set to NEVER I get this exception.

Should we set the flush mode to AUTO? Will this have any negative impact on the transaction management, in other words will the flushing of the session then still be controlled by the existing Transaction?

Comment

I assume you're working with JtaTransactionManager: This issue shouldn't happen with HibernateTransactionManager, which sets the FlushMode of a pre-bound Session temporarily to AUTO for the execution of a non-read-only transaction.

Actually, this shouldn't have worked quite so well with JtaTransactionManager in 1.0.2: While HibernateTemplate did accept write operations in any case, those wouldn't have been flushed at transaction completion, because the JTA session synchronization would only cause a flush if not in FlushMode NEVER. Consequently, as long as you hadn't called flush yourself, your changes would not have been persisted...

Thus, it is indeed currently necessary to set OpenSessionInViewInterceptor/Filter to FlushMode AUTO when working with JtaTransactionManager, to properly get transactional changes flushed. While that will work, it's preferable to have the Session in FlushMode NEVER outside of a transaction: Therefore, I'm gonna look at this issue for the 1.1.1 release.