Win a copy of Programming with Types this week in the Angular and TypeScript forum
or The Design of Web APIs in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

With respect to using CMT Transactions in SessionBeans and Hibernate

 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi .

I have some operations to be performed on the Database . I am using Session Beans and Hibernate for this.

While performing an insertion operation should i set the transaction support from a session Bean using CMT Or

Will it be a good practice to use Transaction in DAO implementation code with the help of Hibernate provided Transaction suppourt.

Please tell me what will be the best approach?
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose it'll be good idea to use your Stateless Session Bean's transaction rather than in the DAO.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

RaviNada Kiran wrote:
Hi .

I have some operations to be performed on the Database . I am using Session Beans and Hibernate for this.

While performing an insertion operation should i set the transaction support from a session Bean using CMT Or

Will it be a good practice to use Transaction in DAO implementation code with the help of Hibernate provided Transaction suppourt.

Please tell me what will be the best approach?



It depends where you need your transactions to start/end. Usually that will be the EJB method but it might not always be the case.
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will be better to start the Transactions in the EJB because
If you have to insert data in two different tables in one transaction, and you are using two different DAOs for those two tables, then its better to start the transaction in the EJB, call the two DAOs in the same transaction..
Also, it is better on rely on CMT unless you explicitly need the control of the transactions to yourself...
But as Paul mentioned, might not always be the case...
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point Rahul .Thanks.

Thanks Paul.
 
Space pants. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!