I\'m using Struts 2.2.1.1 and Hibernate 3.6.2.Final. I\'m also using C3P0 for my connection pool which is running on Tomcat 7.0.11.
I\'m having issues where my Hibe
I've never used the hibernate plugin, but I would encourage you to adopt the Open Session in View pattern. You definitely want to be closing your sessions.
One of the most common ways to handle this is to create a session at the start of the request, store it in a thread local, and then close it at the end of the request. This can be done from a Struts interceptor or a servlet filter. Basically:
public class HibernateSessionInterceptor extends AbstractInterceptor {
@Override
public String intercept(final ActionInvocation invocation) throws Exception {
try {
// create the session and place it in the ThreadLocal
return invocation.invoke();
} finally {
// close the session and remove it from the ThreadLocal
}
}
}
If you use Google Guice, there is a persistence plugin (guice-persist) that is based on JPA. It uses the same approach, but with a servlet filter.