• 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

Session bean tranasactions with CMP

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using session beans in my app, from a session bean I'll call multiple entity beans(CMP) in a transaction. Can any one tell me the best approach to use multiple entity beans(CMP)in a transaction.
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can start the transaction in the session bean and have tx attribute of required in entity bean. I am not sure whether this is of much use to you.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I for one am missing something here. What do you mean by "approach" with regard to the operations being performed within a transactional context? How to lookup beans? How to set transaction attributes? Something else?
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My transaction requires updating the contents of three different CMP entity beans. The update should be performed on all three beans or none.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Just define your transaction attributes (for the session bean as well the entity beans) to "Required". Then, if the session bean is invoked without a transactional context, it will acquire a new one, and if any of the entity beans fail, the whole transaction will be rolled back.
Another question is whether you should use "Required" or "RequiresNew" for the session bean (i.e. whether you want to rollback the caller's transaction or not).
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx!
Can I use UserTransaction for the same purpose? By using context.getUserTransaction(), I can get UserTransaction and then commit or rollback.Is this a good approach?
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can I use UserTransaction for the same purpose? By using context.getUserTransaction(), I can get UserTransaction and then commit or rollback.Is this a good approach?


In the Session bean?
Yes you can .
reply
    Bookmark Topic Watch Topic
  • New Topic