1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
sf = HibernateUtil.getSessionFactory();
try {
log.debug("Starting a database transaction");
sf.getCurrentSession().beginTransaction();
// Call the next filter (continue request processing)
chain.doFilter(request, response);
// Commit and cleanup
log.debug("Committing the database transaction");
sf.getCurrentSession().getTransaction().commit();
} catch (StaleObjectStateException staleEx) {
log.error("This interceptor does not implement optimistic concurrency control!");
log.error("Your application will not work until you add compensation actions!");
throw staleEx;
} catch (Throwable ex) {
ex.printStackTrace();
try {
if (sf.getCurrentSession().getTransaction().isActive()) {
log.error(ParametresMessages.getString("error.production.commit"));
sf.getCurrentSession().getTransaction().rollback();
}
} catch (Throwable rbEx) {
log.error(ParametresMessages.getString("error.production.commit"), rbEx);
}
throw new ServletException(ex);
} |
Partager