We use hibernate since years in a client-server application.
The application handles a huge amount of loaded hibernate objects and work with long running sessions.
A user of this application manipulates this objects in many ways.
We use flush and rollback to control this manipulations. So we use rollback to undo the results of manipulation.
To synchronize with database we refresh the manipulated objects only.
Because of the huge amount of objects these selective refresh is absolutely necessary to get a reasonable performance.
Hibernate 5.2.0 changed the behavior of rollback. Now StatefulPersistenceContext.clear() is called which calls unsetSession() on proxies and collections.
This happens by a change in
Code:
SessionImpl.afterTransactionCompletion(boolean successful, boolean delayed)
Before Hibernate 5.2:
Code:
SessionImpl.afterTransactionCompletion(boolean successful, boolean delayed) {
…
if ( autoClear ) { internalClear(); }
… }
Since Hibernate 5.2
Code:
SessionImpl.afterTransactionCompletion(boolean successful, boolean delayed) {
…
if ( autoClear ||!successful ) { internalClear(); }
… }
As a result of this: objects are without session und all objects have to be refreshed. This is a performance issue.
How to deal with his situation?
Is there a way to rollback the database session without unsetSession() of objects and collections?
Have we overlooked a way to configure this?
Does hibernate definitely considers rollback as the end of Session?
Any suggestions?