Page 1 of 1
About Question enthuware.oce-ejbd.v6.2.461 :
Posted: Mon Jan 04, 2016 6:41 pm
by aazizi.tarik
Hi,
The shema is confusing, under method3() its better to write TxA (so that the transaction is required). Or if you let it like that the answer should be RequiresNew for method3 (which is not the case).
I think that would be better if you can update that question. thanks
Re: About Question enthuware.oce-ejbd.v6.2.461 :
Posted: Tue Jan 05, 2016 8:57 pm
by admin
No, it is correct. As the explanation to option 5 says, "method3 can have Required or RequiresNew because it is executing within a transaction context while its caller, method2, does not have any transaction context." In both the cases, method3 will be executed in a new transaction context.
HTH,
Paul.
Re: About Question enthuware.oce-ejbd.v6.2.461 :
Posted: Wed Jan 06, 2016 3:42 am
by aazizi.tarik
I don't agree with you Paul, because transaction started in method A will be suspended in method 2, and then will resume in method 3 if it's only required, so its not a new transaction context.
The solution should be RequiresNew for method 3 and not Required as mentioned
Re: About Question enthuware.oce-ejbd.v6.2.461 :
Posted: Wed Jan 06, 2016 9:16 am
by admin
Can you please show me in the specification where it says that a transaction that is suspended in a bean will resume in the next bean of the call chain?
Re: About Question enthuware.oce-ejbd.v6.2.461 :
Posted: Wed Jan 06, 2016 9:28 am
by aazizi.tarik
Section 13.6.1:
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. If there is a transaction associated with the instance (this would happen if a stateful session bean instance started the transaction in some previous business method), the container associates the method execution with this transaction.
And that was your explanation regarding
the question 2.611.
Re: About Question enthuware.oce-ejbd.v6.2.461 :
Posted: Wed Jan 06, 2016 9:56 am
by admin
The explanation that you have quoted is describing a different case. It is talking about the case where a transaction was started by a bean (say, Bean X) in a method and that method has returned without committing or rolling back the transaction. Now, another call is made to the same bean X. In this call, the previously created transaction will be associated.
The situation in this question is totally different. There is no previous call here. There is no transaction associated in method 2 and method 3 from any previous call. There is only one chain of calls where a methodA calls method2 of some bean, which in turn calls a method2 in some bean.
In this situation, methodA hasn't returned. It is the same call chain in which it calls method1, and in this method the transaction of methodA is suspended. Now, as far as method2 is concerned the caller (i.e. method1) has no transaction and method2 does not have any previously created transaction. So a new transaction will be created.
HTH,
Paul.
Re: About Question enthuware.oce-ejbd.v6.2.461 :
Posted: Wed Jan 06, 2016 10:21 am
by aazizi.tarik
You are right.
And many thanks for your time and clear explanation. It's also specified in the specs like what you said, section 13.6.2.1 (regarding NOT_SUPPORTED):
If a client calls with a transaction context, the container suspends the association of the transaction context with the current thread before invoking the enterprise bean’s business method. The container resumes the suspended association when the business method has completed. The suspended transaction context of the client is not passed to the resource managers or other enterprise bean objects that are invoked from the business method.
If the business method invokes other enterprise beans, the container passes no transaction context with the invocation.