About Question enthuware.oce-ejbd.v6.2.461 :

Moderator: admin

Post Reply
aazizi.tarik
Posts: 31
Joined: Sun Dec 27, 2015 1:47 pm
Contact:

About Question enthuware.oce-ejbd.v6.2.461 :

Post 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

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

Re: About Question enthuware.oce-ejbd.v6.2.461 :

Post 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.
If you like our products and services, please help us by posting your review here.

aazizi.tarik
Posts: 31
Joined: Sun Dec 27, 2015 1:47 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.461 :

Post 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

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

Re: About Question enthuware.oce-ejbd.v6.2.461 :

Post 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?
If you like our products and services, please help us by posting your review here.

aazizi.tarik
Posts: 31
Joined: Sun Dec 27, 2015 1:47 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.461 :

Post 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.

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

Re: About Question enthuware.oce-ejbd.v6.2.461 :

Post 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.
If you like our products and services, please help us by posting your review here.

aazizi.tarik
Posts: 31
Joined: Sun Dec 27, 2015 1:47 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.461 :

Post 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.

Post Reply

Who is online

Users browsing this forum: No registered users and 75 guests