dcsimg
How to maintaining the Transaction in session bean?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vijay_Kumar
Posted On:   Wednesday, February 6, 2002 09:42 PM

Hi ! I have a stateless session bean which has a business method called inserRows(), which inturn calls three BMP entity bean's create method to insert rows into three diffarent tables. my problem if all the create methods executed all of them execute successfully or else all of then should not be executed. i mean if there is any problem in inserting of a row in any entity bean(table) all the rows inserted should be rolledback.if there is no problem then all the rows should be inserted( either all the rows should be inserted or rolled back). for that i am doing like this. public boolean inserRows() {      UserTransaction ut = null;      try {    More>>

Hi ! I have a stateless session bean which has a business method
called inserRows(), which inturn calls three BMP entity bean's create method to
insert rows into three diffarent tables. my problem if all the create methods
executed all of them execute successfully or else all of then should not be executed.
i mean if there is any problem in inserting of a row in any entity bean(table) all the rows
inserted should be rolledback.if there is no problem then all the rows should be
inserted( either all the rows should be inserted or rolled back).
for that i am doing like this.



public boolean inserRows() {


     UserTransaction ut = null;

     try {

          ut = (UserTransaction)ic.lookup("javax.transaction.UserTransaction");

          ut.begin();

          entitybean1.create(.......)

          entitybean2.create(.......)

          entitybean3.create(.......)

          ut.commit();

          return true;

     } catch(Exception ex) {

          ut.rollback();

          return false;

     }

}



but this is not working.
here ic is an object of InitialContext.


any help will be appreciated

   <<Less

Re: How to maintaining the Transaction in session bean?

Posted By:   Bozidar_Dangubic  
Posted On:   Thursday, February 7, 2002 07:39 AM

what is the transactional attribute of entitybean1,entitybean2,entitybean3's create() method?
About | Sitemap | Contact