| Author |
With respect to using CMT Transactions in SessionBeans and Hibernate
|
RaviNada Kiran
Ranch Hand
Joined: Jan 30, 2009
Posts: 528
|
|
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?
|
If you want something you never had do something which you had never done
|
 |
Rahul Babbar
Ranch Hand
Joined: Jun 28, 2008
Posts: 210
|
|
|
I suppose it'll be good idea to use your Stateless Session Bean's transaction rather than in the DAO.
|
Rahul Babbar
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
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.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Rahul Babbar
Ranch Hand
Joined: Jun 28, 2008
Posts: 210
|
|
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
Joined: Jan 30, 2009
Posts: 528
|
|
Good point Rahul .Thanks.
Thanks Paul.
|
 |
 |
|
|
subject: With respect to using CMT Transactions in SessionBeans and Hibernate
|
|
|