-->
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.  [ 8 posts ] 
Author Message
 Post subject: EJB Transaction and Hibernate
PostPosted: Tue Mar 15, 2005 2:47 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
Hi,

I am using Hibernate v2.1.7. Can someone please point me to the documentation where it states NOT to explicitly call begin transaction and commit transaction in an EJB transaction (say using Weblogic)?

I've repeatedly searched the "Hibernate in Action" book and online docs, but can't seem to find ample documentation on this.

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 6:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Senario: Call to a SLSB that is CMT. Hibernate transaction performed.

The transaction is managed by the container so there is no need to call the transaction API.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 7:53 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
david wrote:
Senario: Call to a SLSB that is CMT. Hibernate transaction performed.

The transaction is managed by the container so there is no need to call the transaction API.


Thanks. What is SLSB?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 8:45 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Stateless Session bean


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 12:42 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
drj wrote:
Stateless Session bean


Thanks for the response. So, now I have two questions:

1. Is it necessary I use JTA with Hibernate in an EJB container? (Dis)advantages?

2. If I use JTA, then I only have to open, flush, and close the session to commit to the database?

I appreciate your help. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 7:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There is little point in using a EJB container if your not using the facilties it offers (and is good at). Container Managed Transactions (CMT) is one of these facilties. Do you have to? NO. Should you? YES. It saves you a lot of work and concern.

Yes open, flush and close. Don't forget the include appropriate exception handling and rollback hint as required.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 9:22 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
david wrote:
There is little point in using a EJB container if your not using the facilties it offers (and is good at). Container Managed Transactions (CMT) is one of these facilties. Do you have to? NO. Should you? YES. It saves you a lot of work and concern.

Yes open, flush and close. Don't forget the include appropriate exception handling and rollback hint as required.


Thanks David. My problems were occuring because I didn't have the ejb.transaction flag set to "Required", instead it was set to "Supports". Now, when I open, flush, and close the session - it works just fine.

One last question, what 'rollback hint' are you referring to? You did not mention any nor have I read about it.

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 17, 2005 9:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
CMT Context object has a method that allows you to tell (a hint to) the CMT engine to rollback the transaction rather than commiting it. Obviously, this would only normally happen if there was an exception of some description. Look at the J2EE API or an approrpiate EJB book for examples.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.