Transaction Handling - Specifically flush before leaving UI scope

Hello, I am having trouble getting pending DB updates flushed before UI rendering completes in Vaadin and after events have been processed.

I am working on a Vaadin application that serves as a frontend for a Spring+Hibernate implemented application logic. There is a servlet filter that closes the database transaction, if any is open. It is desired, that the transaction (and so the Hibernate session) stays open until after rendering by Vaadin as to make sure not to have premature detach of entities.

Now… on the other side I would like to flush any pending updates before the user interface rendering completes to make sure to tell the user that some update was not successful, if it fails for some database problem (e.g. some validation constraint). While those errors should not happen in the first place, not telling the user something went wrong is not a good option.

In order to make sure, I can flush any pending updates, I would need to know when event processing completed and I can still show an error (i.e. before rendering is done).

I am using Vaadin 8.4 at the moment.

Any help appreciated.

Thanks,
Henning

I would recommend to think this in opposite direction. I.e. perform database operations asynchronously and push updates to UI.