TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
if( LOG.isDebugEnabled()) LOG.debug("Hibernate Session is bounded to Job thread");
}
public void jobWasExecuted(JobExecutionContext context, JobExecutionException exception) {
SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory);
if(!FlushMode.MANUAL.equals(sessionHolder.getSession().getFlushMode())) {
sessionHolder.getSession().flush();
}
SessionFactoryUtils.closeSession(sessionHolder.getSession());
if( LOG.isDebugEnabled()) LOG.debug("Hibernate Session is unbounded from Job thread and closed");
}