Index: lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java,v diff -u -r1.6 -r1.7 --- lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java 11 Sep 2015 15:31:09 -0000 1.6 +++ lams_common/src/java/org/lamsfoundation/lams/web/filter/TransactionRetryInterceptor.java 11 Sep 2015 15:33:48 -0000 1.7 @@ -27,12 +27,15 @@ import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.lang.mutable.MutableInt; import org.apache.log4j.Logger; +import org.hibernate.FlushMode; +import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.LockAcquisitionException; import org.lamsfoundation.lams.util.ITransactionRetryService; import org.springframework.dao.CannotAcquireLockException; import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.orm.hibernate3.SessionFactoryUtils; import org.springframework.transaction.UnexpectedRollbackException; /** @@ -88,6 +91,11 @@ attempt.increment(); if (attempt.intValue() <= TransactionRetryInterceptor.MAX_ATTEMPTS) { message.append(". Retrying."); + + // the exception could have closed the session; try to recreate it here + Session session = SessionFactoryUtils.getSession(sessionFactory, true); + // same as in CustomizedOpenSessionInViewFilter + session.setFlushMode(FlushMode.AUTO); } else { message.append(". Giving up."); } @@ -99,6 +107,6 @@ } public void setSessionFactory(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; + this.sessionFactory = sessionFactory; } } \ No newline at end of file