-->
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.  [ 2 posts ] 
Author Message
 Post subject: When will Hibernate actually commit the database?
PostPosted: Wed Jan 26, 2011 11:21 pm 
Newbie

Joined: Fri Feb 05, 2010 1:05 am
Posts: 12
Hi everyone,
I am using hibernate 3.3.2 in ejb3 with jta
Code:
       <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
       <property name="jta.UserTransaction">java:comp/UserTransaction</property>
       <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
         <property name="current_session_context_class">jta</property>


What I am trying to do in the ejb method is update the db and commit, then calling a remote web service, which also access the same db to proceed. And if the web service failed, the ejb method would do some manual rollback(since already previously committed).

However, it seems the db is in deadlock state after the first ejb commit and processing the web service. So I m wondering if the db is locked.

So my question is, will hibernate physically commit and release the db connection with the above configuration used? If not, how can I achieve it? Or should I have to use managed transaction instead?

Here's some code I used within the ejb method
Code:
       try{
         
          session = HibernateUtil.getSessionFactory().openSession();
      tx = session.beginTransaction();   
         
      //do something
          
      session.flush();         
      tx.commit();          
          
       }
   catch(Exception err){
         if (tx != null && tx.isActive()) tx.rollback();          
   }finally{         
      if(session != null && session.isOpen())
      {
            
         session.close();
      }
   }


Top
 Profile  
 
 Post subject: Re: When will Hibernate actually commit the database?
PostPosted: Thu Jan 27, 2011 9:46 pm 
Newbie

Joined: Fri Feb 05, 2010 1:05 am
Posts: 12
up.

Another question, I am using BMT in this EJB and there's two transactions in the same EJB method. Will the first session physically closed when I called tx.commit()? Or it only closed until end of the life of the method?


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

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.