About Question enthuware.oce-jpad.v6.2.392 :

Moderator: admin

Post Reply
romsky
Posts: 39
Joined: Thu Jan 29, 2015 4:49 pm
Contact:

About Question enthuware.oce-jpad.v6.2.392 :

Post by romsky » Sun Aug 30, 2015 1:09 pm

I do not understand the explanation for 5th varian.
==
Since the question specifies that anotherBean.anotherMethod() executes in the same transaction that is started by myMethod(), anotherBean must be a CMT bean because if it were a BMT bean, the transaction started by myMethod() would have been suspended.
==

What is wrong if the transaction started by myMethod() would have been suspended?
If it is suspended, anotherMethod could not rollback it.

admin
Site Admin
Posts: 7551
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.392 :

Post by admin » Sun Aug 30, 2015 8:21 pm

The problem statement states that the second bean's method executes in the same transaction as the first bean. BMT will not satisfy this part of the problem.
If you like our products and services, please help us by posting your review here.

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.392 :

Post by __JJ__ » Thu Sep 20, 2018 8:12 pm

Since the question specifies that anotherBean.anotherMethod() executes in the same transaction that is started by myMethod(), anotherBean must be a CMT bean because if it were a BMT bean, the transaction started by myMethod() would have been suspended.
How would it (the method in BMT bean anotherMethod) have been suspended? I thought that transactions are suspended by the use of

Code: Select all

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
and that

Code: Select all

@TransactionAttribute
could only be used in CMT beans:
The TransactionAttribute annotation specifies whether the container is to invoke a business method within a transaction context. The TransactionAttribute annotation can be used for session beans and message driven beans. It can only be specified if container managed transaction demarcation is used.
Thanks.

admin
Site Admin
Posts: 7551
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.392 :

Post by admin » Thu Sep 20, 2018 8:40 pm

As per section 13.6.1 of EJB 3.1 Specification:
The container must manage client invocations to an enterprise bean instance with bean-managed transaction demarcation as follows. When a client invokes a business method via one of the enterprise bean’s client views, the container suspends any transaction that may be associated with the client request.
In the situation given in the question, if the given code calls anotherBean used BMT, the transaction started by this code would have to be suspended.
If you like our products and services, please help us by posting your review here.

__JJ__
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.392 :

Post by __JJ__ » Thu Sep 20, 2018 11:56 pm

I've just seen this in ProJPA2 which confirms what you're saying:
One penalty of transactions being managed by the application instead of by the container is that they do not get propagated to methods called on another BMT bean. For example, if Bean A begins a transaction and then calls Bean B, which is using bean-managed transactions, then the transaction will not get propagated to the method in Bean B. Any time a transaction is active when a BMT method is invoked, the active transaction will be suspended until control returns to the calling method.
I think what I need to get my head around is that managing transactions in BMT is not as analagous to managing transactions in Java SE with EntityManager as I have been thinking it was. There is still "container stuff" going on, like here. A transaction is suspended, but not because an annotation was specified, nor because you called some txsuspend() method or other; it's just suspended, because, well, that's just how it works.

Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest