• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Two EJB problem

 
Ranch Hand
Posts: 464
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey thanks a ton .. it worked

Regards
Venkatesh S
 
reply
    Bookmark Topic Watch Topic
  • New Topic