spring-webflow icon indicating copy to clipboard operation
spring-webflow copied to clipboard

Make Session flush mode configurable in HibernateFlowExecutionListener [SWF-1205]

Open spring-operator opened this issue 15 years ago • 2 comments

Mauricio Noda opened SWF-1205 and commented

There´s no easy way to set Session flush mode in HibernateFlowExecutionListener.


Affects: 2.0.8

spring-operator avatar Jan 27 '10 23:01 spring-operator

Rossen Stoyanchev commented

It would be helpful if you could describe your specific scenario.

spring-operator avatar Jan 27 '10 23:01 spring-operator

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.

spring-operator avatar Jan 28 '10 07:01 spring-operator