Hello,

Today I was looking in HibernateTransactionManager implementation, and I saw that when a rollback occours, there is a way to avoid that the hibernate session be closed in all entities, setting the property hibernateManagedSession to true (in 2,5,6 codebase is around line 684).

...
if (!txObject.isNewSession() && !this.hibernateManagedSession) {
// Clear all pending inserts/updates/deletes in the Session.
// Necessary for pre-bound Sessions, to avoid inconsistent state.
txObject.getSessionHolder().getSession().clear();
}
...


Then I tried to search similar functionality in JtaTransactionManager. The class SpringSessionSynchronization to similar activity for this type of transaction management, but it doesn't have similar property, like hibernateManagedSession, to avoid the cleanup of the session (line 226):

...
if (!this.newSession && status != STATUS_COMMITTED) {
// Clear all pending inserts/updates/deletes in the Session.
// Necessary for pre-bound Sessions, to avoid inconsistent state.
this.sessionHolder.getSession().clear();
}
...


Is there any reason to this? I really like avoid this type of call. My problem is that after a rollback, I use OpenSessionInView, and after a rollback , all objects calls that is not initialized I receive LazyInitializationException. I must postpone this clear to OpenSessionInView.

Any tip?