cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Cocoon Wiki] Update of "CocoonAndHibernateTutorial" by JohannesTextor
Date Fri, 22 Apr 2005 06:58:10 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.

The following page has been changed by JohannesTextor:
http://wiki.apache.org/cocoon/CocoonAndHibernateTutorial

The comment on the change is:
Filter: Don't try to open a session when there is none - Thanks Brent Johnson ! 

------------------------------------------------------------------------------
      
      // After cocoon has finished processing, close the 
      // corresponding Hibernate session if it has been opened 
-     if(((HttpServletRequest)request).getSession() != null && 
+     if(((HttpServletRequest)request).getSession(false) != null && 
      ((HttpServletRequest)request).getSession().getAttribute("DisposeHibernateSession")!=null)
      {
-     	Session hs = (Session) ((HttpServletRequest)request).getSession().getAttribute("DisposeHibernateSession");
+      Session hs = (Session) ((HttpServletRequest)request).getSession().getAttribute("DisposeHibernateSession");
-     	try{
+      try{
-     		hs.flush();
+       hs.flush();
-     		hs.connection().close();
+       hs.connection().close();
-     		hs.close();
+       hs.close();
-     	}
+      }
-     	catch( HibernateException e ){
+      catch( HibernateException e ){
-     		System.out.println(e.getMessage());
+       System.out.println(e.getMessage());
-     	}
+      }
-     	catch( SQLException e ){
+      catch( SQLException e ){
-     		System.out.println(e.getMessage());
+       System.out.println(e.getMessage());
      	}
      	((HttpServletRequest)request).getSession().setAttribute("DisposeHibernateSession",null);
      }

Mime
View raw message