Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Two EJB problem  RSS feed

 
S Venkatesh
Ranch Hand
Posts: 464
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have 2 EJB's. EJB1 which updates a record in table A and EJB2 which updates the record in table B.

Now i need to call both EJB's to accomplish my task from a delegate. My question is if the first update to table A is sucessful and update to table B fails, then will i be able to roll back the transaction that occured by calling EJB1?

Regards
Venkatesh S
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, no problem. One way is to define, say, an EJB update() method (that your delegate will call) which calls the methods of EJB1 and EJB2. Set the transaction attribute of the update() method to Required and both the invoked methods of EJB1 and EJB2 to Required. This will cause the methods of EJB1 and EJB2 to run in update()'s transaction. If the transaction is marked for rollback due to a problem in EJB2, the entire transaction will rollback - this applies to all updates to both tables.
 
S Venkatesh
Ranch Hand
Posts: 464
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks a ton .. it worked

Regards
Venkatesh S
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!