-
Feb 16th, 2009, 02:16 PM
#1
HibernateTransactionManager vs JtaTransactionManager
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules