• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Big question on transactions

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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
 
Joe Nguyen
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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?
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic