-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: afterTransactionCompletion() was never called
PostPosted: Tue Mar 02, 2004 7:35 am 
Newbie

Joined: Tue Mar 02, 2004 7:25 am
Posts: 3
Hello guys,

I'm using Hibernate but I'm having a warning...

This warning is about don't close the session?
Code:
net.sf.hibernate.impl.SessionImpl  afterTransactionCompletion() was never called


I'm using Struts. I always open a Transaction, do commit/rollback and close the Hibernate Session in the finally method... I use ThreadLocal pattern too.

please, can somebody help me? My code is correct?
HibernateThreadLocalSession is a class wich implement ThreadLocal pattern.

thank you very much

Code:
HttpSession session = request.getSession();

      Transaction t = null;

      try
      {
         try
         {
            t = HibernateThreadLocalSession.currentSession().beginTransaction();
            
         }
         catch (RuntimeException e)
         {
            System.out.println(e.getMessage());
            e.printStackTrace();
         }

         // abstract method, all subclasses implement it, I use DAO pattern and TreadLocal
         ActionForward forward = performDBTask(mapping, form, request, response);

         if (request.getAttribute("org.apache.struts.action.ERROR") == null)
         {
            t.commit();
         }
         else
         {
            t.rollback();
         }
         return forward;
      }
      catch (Exception exPA)
      {
         exPA.printStackTrace();

         try
         {
            if (t != null)
            {
               t.rollback();
            }
         }
         catch (HibernateException e1)
         {
            System.out.println("Error rollback: " + e1.getClass() + " - " + e1.getMessage());
         }

      finally
      {

         // close session in threadlocal
         HibernateThreadLocalSession.closeSession();
      }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.