-->
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.  [ 4 posts ] 
Author Message
 Post subject: Session close and Transaction commit
PostPosted: Thu Jan 29, 2004 12:31 pm 
Newbie

Joined: Thu Dec 04, 2003 3:10 pm
Posts: 9
Location: Rio de Janeiro, Brazil
Hi,

I have en EJB that call another EJB that opens a session using ThreadLocal pattern and after do some work getting other session. That looks like this:

Code:
public void methodA(Object obj)
{
  methodB(obj.getChild()); // in another EJB
  session = ThreadLocalSession.currentSession();
  delete(obj)
  session.flush();
  ThreadLocalSession.closeSession();
}

public void methodB(Object obj)
{
  session = ThreadLocalSession.currentSession();
  delete(obj)
  session.flush();
  ThreadLocalSession.closeSession();
}

I'm closing the Session in the methodB but I want that both delete operations be part of the same transaction. I'm using JTA transaction with CMT. The question is :
The Session.close() commits the transaction ? Or the container do this ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 5:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If you are using JTA in an EJB environment, the container handles your transactions for you, using the declarative transaction settings you declare in your deployment descriptor. At least that is the usual way.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 6:36 pm 
Newbie

Joined: Thu Dec 04, 2003 3:10 pm
Posts: 9
Location: Rio de Janeiro, Brazil
Even if I close the session ?

I supposed that the container manages with if I use transaction.commit()...

So, I don


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2004 8:00 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
joaocm wrote:
Even if I close the session ?

Yes

joaocm wrote:
I supposed that the container manages with if I use transaction.commit()...

No with CMT, tx will be commited by the EJB if neither:
- ctx.setRollbackOnly() as been set
- runtime exception is throwned through the EJB layer

joaocm wrote:
So, I don

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.