• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

With respect to using CMT Transactions in SessionBeans and Hibernate

 
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point Rahul .Thanks.

Thanks Paul.
 
reply
    Bookmark Topic Watch Topic
  • New Topic