Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transaction Propagation Question ??

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

SWe have two Stateless ession beans S1 and S2.

S1 uses container managed transaction demarcation.
S2 uses bean managed transaction demarcation.

S1 starts a transaction and calls method on S2.

Will the transaction be propagated from S1 to S2
assuming that the method on S2 uses bean managed transaction demarcation ???


Thanks in advance.
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is a good question.
As far as I know, it is fine for a container-managed method to call a bean-managed method on another bean.

Will the transaction propagate ? That depends on the choosen transaction attribute for this bean-managed method:
Required, RequiresNew, Manadatory, NotSupported, Supports, Never.
Check the rules for each of these attributes.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The transaction started in S1 will be temporarily suspended. The BMT in S2 is new transaction. The transaction attributes are applicable only for container-managed transactions and not for Bean managed transaction. The BMT always start new transaction.

Thanks
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Celinio Fernandes:

Will the transaction propagate ? That depends on the choosen transaction attribute for this bean-managed method:
Required, RequiresNew, Manadatory, NotSupported, Supports, Never.
Check the rules for each of these attributes.


These attributes are present only for Container manager transaction demarcation. Bean managed demarcation starts a transaction using begin on UserTransaction object.

Coming to the original question,
In such a scenario, as ejbs does not support nested transactions, the transaction from bean S1 will be suspended before starting a new transaction in S2. When the transaction is S2 finishes, S1 will be resumed.
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed, I got mixed up with the different scenarios and replied too quickly ! :roll:

A different bean with bean-managed transaction demarcation means new transaction of course.
[ December 27, 2007: Message edited by: Celinio Fernandes ]
 
Kamlesh Devani
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will the transaction propagate ? That depends on the choosen transaction attribute for this bean-managed method:
Required, RequiresNew, Manadatory, NotSupported, Supports, Never.
Check the rules for each of these attributes.



These attributes are present only for Container manager transaction demarcation. Bean managed demarcation starts a transaction using begin on UserTransaction object.


I have a doubt.
suppose if a client with a transactional context Required calls a method on a session bean with bean managed transaction what would be the result?
Thanks in advance.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kamlesh Devani:

I have a doubt.
suppose if a client with a transactional context Required calls a method on a session bean with bean managed transaction what would be the result?
Thanks in advance.


No difference then what i have told in my earlier post.
Suspension of the current transaction is because of the fact that ejb does not support nested transactions and that is true irrespective of the transactional requirements of the calling method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic