• 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

Big question on transactions

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am running a session bean method (method A) inside a transaction, then I call a method (method B) of my delegate (a plain Java Class) and this method calls a method (method C) in another session bean with "supported" transaction attribute.

Does anyone knows if the initial transaction will reach method C?


method A --> method B --> method C
(server) (POJO) (server)


Fabio Scopeta
Systems Architect
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it will since the method B is in the same transaction initiated by method A (logically method A and method B are in the same session). Method C, which has transaction attribute support, will use the same transaction as in method A.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But method B is not a EJB, it's a plain Java class. Isn't that a problem?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let'me understand... If a call a method in a simple Java class from my Session Bean, this method works as it was a Session Bean business method?
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Transactions propagate to POJOs as well when invoked by an EJB.
 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a call a method in a simple Java class from my Session Bean, this method works as it was a Session Bean business method

Yes, it does. As long as it calls from a session bean with CMT, the container will manage the transaction.

Instead of putting business logic in the bean, you can have dependent classes implementing business logic and delegate request to the dependent classes. One of the benefit you can get is the flexibility. You can config your app to run in ejb container or just pure jvm at run time.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic