1 package org.hibernate.ce.auction.persistence; 2 3 import org.apache.commons.logging.*; 4 5 import javax.servlet.*; 6 import java.io.IOException ; 7 8 22 public class HibernateFilter implements Filter { 23 24 private static Log log = LogFactory.getLog(HibernateFilter.class); 25 26 public void init(FilterConfig filterConfig) throws ServletException { 27 log.info("Servlet filter init, now opening/closing a Session for each request."); 28 } 29 30 public void doFilter(ServletRequest request, 31 ServletResponse response, 32 FilterChain chain) 33 throws IOException , ServletException { 34 35 try { 40 chain.doFilter(request, response); 41 42 HibernateUtil.commitTransaction(); 44 45 } finally { 46 47 HibernateUtil.closeSession(); 49 50 } 51 } 52 53 public void destroy() {} 54 55 } | Popular Tags |