3 Replies Latest reply on Nov 4, 2005 7:18 AM by julien1

    Closing hibernate sessions

    Martin Giljohann Newbie

      Hello, I have a question concerning hibernate with the portal. For my application I followed
      and deploy the mappings inside a *.har, which is inside an *.ear - no problem.

      To get the Session I'm using JBP code from org.jboss.portlet.forums.impl.ForumsModuleImpl#getSession

      SessionFactory sf = (SessionFactory)new InitialContext().lookup("java:/portal/SessionFactory");
       Session session = sf.getCurrentSession();
       return session;
       catch (NamingException e)
       throw new RuntimeException(e);

      For the queries I looked at other methods from ForumsModuleImpl and I saw that the sessions are never closed here. However in the above linked docs they are closed in a finally block. Is this not necessary because the container somewhat takes care about this?