private void closeSession() { if (this.timeoutInProgress || this.errorInProgress) { logger.debug("Closing Hibernate Session after async request timeout/error"); SessionFactoryUtils.closeSession(this.sessionHolder.getSession()); } }
private void closeSession() { if (this.timeoutInProgress || this.errorInProgress) { logger.debug("Closing Hibernate Session after async request timeout/error"); SessionFactoryUtils.closeSession(this.sessionHolder.getSession()); } }
/** * Unbind the Hibernate {@code Session} from the thread and close it). * @see TransactionSynchronizationManager */ @Override public void afterCompletion(WebRequest request, @Nullable Exception ex) throws DataAccessException { if (!decrementParticipateCount(request)) { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(obtainSessionFactory()); logger.debug("Closing Hibernate Session in OpenSessionInViewInterceptor"); SessionFactoryUtils.closeSession(sessionHolder.getSession()); } }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { SessionFactory sf = getSessionFactory(); Assert.state(sf != null, "No SessionFactory set"); if (!TransactionSynchronizationManager.hasResource(sf)) { // New Session to be bound for the current method's scope... Session session = openSession(sf); try { TransactionSynchronizationManager.bindResource(sf, new SessionHolder(session)); return invocation.proceed(); } finally { SessionFactoryUtils.closeSession(session); TransactionSynchronizationManager.unbindResource(sf); } } else { // Pre-bound Session found -> simply proceed. return invocation.proceed(); } }
@Override public void afterCompletion(int status) { try { if (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(); } } finally { this.sessionHolder.setSynchronizedWithTransaction(false); // Call close() at this point if it's a new Session... if (this.newSession) { SessionFactoryUtils.closeSession(this.sessionHolder.getSession()); } } }
/** * Unbind the Hibernate {@code Session} from the thread and close it). * @see TransactionSynchronizationManager */ @Override public void afterCompletion(WebRequest request, @Nullable Exception ex) throws DataAccessException { if (!decrementParticipateCount(request)) { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(obtainSessionFactory()); logger.debug("Closing Hibernate Session in OpenSessionInViewInterceptor"); SessionFactoryUtils.closeSession(sessionHolder.getSession()); } }
@Override public Object invoke(MethodInvocation invocation) throws Throwable { SessionFactory sf = getSessionFactory(); Assert.state(sf != null, "No SessionFactory set"); if (!TransactionSynchronizationManager.hasResource(sf)) { // New Session to be bound for the current method's scope... Session session = openSession(sf); try { TransactionSynchronizationManager.bindResource(sf, new SessionHolder(session)); return invocation.proceed(); } finally { SessionFactoryUtils.closeSession(session); TransactionSynchronizationManager.unbindResource(sf); } } else { // Pre-bound Session found -> simply proceed. return invocation.proceed(); } }
SessionFactoryUtils.closeSession(session);
@Override public void afterCompletion(int status) { try { if (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(); } } finally { this.sessionHolder.setSynchronizedWithTransaction(false); // Call close() at this point if it's a new Session... if (this.newSession) { SessionFactoryUtils.closeSession(this.sessionHolder.getSession()); } } }
logger.debug("Closing Hibernate Session [" + session + "] after transaction"); SessionFactoryUtils.closeSession(session);
if (!isAsyncStarted(request)) { logger.debug("Closing Hibernate Session in OpenSessionInViewFilter"); SessionFactoryUtils.closeSession(sessionHolder.getSession());
SessionFactoryUtils.closeSession(session);
logger.debug("Closing Hibernate Session [" + session + "] after transaction"); SessionFactoryUtils.closeSession(session);
if (!isAsyncStarted(request)) { logger.debug("Closing Hibernate Session in OpenSessionInViewFilter"); SessionFactoryUtils.closeSession(sessionHolder.getSession());
SessionFactoryUtils.closeSession(session); txObject.setSessionHolder(null);
SessionFactoryUtils.closeSession(session); txObject.setSessionHolder(null);
private void unbindSession() { SessionFactory sessionFactory = (SessionFactory) webApplicationContext.getBean( "sessionFactory" ); SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager .unbindResource( sessionFactory ); SessionFactoryUtils.closeSession( sessionHolder.getSession() ); }
public static void unbindSessionFromThread( SessionFactory sessionFactory ) { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource( sessionFactory ); SessionFactoryUtils.closeSession( sessionHolder.getSession() ); } }
/** * Unbind the Hibernate {@code Session} from the thread and close it). * @see TransactionSynchronizationManager */ @Override public void afterCompletion(WebRequest request, @Nullable Exception ex) throws DataAccessException { if (!decrementParticipateCount(request)) { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(obtainSessionFactory()); logger.debug("Closing Hibernate Session in OpenSessionInViewInterceptor"); SessionFactoryUtils.closeSession(sessionHolder.getSession()); } }
/** * Unbinds and closes the bound Hibernate Session from the current thread. */ private void unbindSession() { SessionFactory sessionFactory = (SessionFactory) getBean( "sessionFactory" ); SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource( sessionFactory ); SessionFactoryUtils.closeSession( sessionHolder.getSession() ); } }