From: Colin E. <ce...@mo...> - 2002-08-27 20:59:55
|
Hi Brad, I haven't tried this yet, but if I wanted to use lazy loading with Struts, I would probably override ActionServlet and do something like this, and have my DAO layer pull the session from the request context as needed: ---- /** * Hibernate Action Servlet */ public class HibernateActionServlet extends ActionServlet { public void service(HttpServletRequest request, HttpServletResponse response) { Session session = null; try { session = factory.openSession(); request.setAttribute("session", session); super.service(request, response); } finally { if(session != null) session.close(); } } } ---- Do other frameworks allow the controller servlet to be overridden? This probably is a fairly straightforward way to get lazy loading working. -Colin -- Colin Evans Mobilesys www.mobilesys.com |