spring-webflow
spring-webflow copied to clipboard
Make Session flush mode configurable in HibernateFlowExecutionListener [SWF-1205]
Mauricio Noda opened SWF-1205 and commented
There´s no easy way to set Session flush mode in HibernateFlowExecutionListener.
Affects: 2.0.8
Mauricio Noda commented
When a transaction is opened in Spring Framework, Session flush mode is automatically changed from MANUAL (default) to AUTO. This is to ensure a flush happens before commit. So the Session starts being flushed before every find and after every save, update or delete. COMMIT flush mode also ensures a flush happens, but with more control on when it happens. Spring Framework keeps the COMMIT setting inside a transaction.
The primary issue is performance. With AUTO flush mode, Hibernate updates the database with almost every call to the API. With COMMIT flush mode, the database is batch updated once at the end of the transaction.
It is also harder to catch exceptions like StaleObjectStateException. With MANUAL flush mode, only Session.flush() method throws this exception. With COMMIT flush mode you can call Session.flush() programatically for the same purpose. With AUTO flushing, any find, save, update or delete can throw the exception.
See issue #414.