Page 1 of 2

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

Posted: Wed May 04, 2011 3:02 pm
by deadlock_gr
The class definition should be visible for XBean to show that no TransactionalAttribute is specified. We can't just assume that REQUIRED is implied since we can't see the class definition.

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

Posted: Sat May 07, 2011 8:22 am
by admin
Hello,

REQUIRED is the default so even if you don't see it, you should assume it as REQUIRED. This is also noted in the explanation for option 3.

HTH,
Paul.

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

Posted: Sun May 08, 2011 2:29 pm
by deadlock_gr
Even though, we can't see the class definition to see that no other value has been specified. If we could see the class definition, to see that REQUIRED has not been overridden, we are in no position to be sure that it hasn't.

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

Posted: Sun May 08, 2011 2:53 pm
by admin
The question also clearly says, "In absense of any other deployment information related to these beans, ...". So I don't think there is any scope to infer that the transaction attribute has been overridden.

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

Posted: Sun Jan 15, 2012 8:20 am
by goetz
FYI, I was confused the same way as deadlock_gr, and didn't think I could assume XBean has the default REQUIRED transaction attribute.

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

Posted: Sun Mar 25, 2012 11:04 am
by Alan
why 'If the client does not have a transaction context, only one transaction context will be used.' is wrong?

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

Posted: Sun Mar 25, 2012 8:12 pm
by admin
Because as option 3 explains, "Since by default the transaction context of a bean is REQUIRED, there will be one transaction context for XBean (either the client's txn context will be used or a new one will be created for XBean) and since the transaction context is never propagated to an asynchronous invocation, a new one is created for YBean also. "

So there will be two transaction contexts created even if the client doesn't have any transaction context.

HTH,
Paul.

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

Posted: Tue Jul 24, 2012 2:39 am
by Frits Walraven
I think there is a @Stateless missing (and the class def.) on the XBean.java, because the question states:

"Consider the following code for two stateless beans" and
"In absense of any other deployment information"

Regards,
Frits Walraven

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

Posted: Tue Jul 24, 2012 8:57 pm
by admin
The fact that XBean is stateless is already given in the question. The question also says in absence of any other deployment information (and not "in absence of any deployment information in the bean"). So I think a complete class definition for XBean is not required for the purpose of this question.


HTH,
Paul.

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

Posted: Sat Aug 17, 2013 2:53 pm
by sanju.ait@gmail.com
"If the client does not have a transaction context, only one transaction context will be used."

This seems to be a better option compared to assuming XBean is already in transaction by default.

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

Posted: Sat Aug 17, 2013 6:19 pm
by admin
sanju.ait@gmail.com wrote:"If the client does not have a transaction context, only one transaction context will be used."

This seems to be a better option compared to assuming XBean is already in transaction by default.
Did you read the explanation for option 3? It explains exactly why 2 transactions will be created whether the client has a transaction or not.

HTH,
Paul.

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

Posted: Wed Nov 12, 2014 3:07 pm
by ssoltanid
I read this topic and the answer to the question.
could be asked This kind of question at the exam ?

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

Posted: Thu Nov 13, 2014 8:11 pm
by admin
Yes, it is possible.

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

Posted: Thu Jan 29, 2015 1:33 pm
by renatumb
admin wrote:Hello,

REQUIRED is the default so even if you don't see it, you should assume it as REQUIRED. This is also noted in the explanation for option 3.

HTH,
Paul.
Just a complement:
YBean is annotated with REQUIRED, even without this annotation it would run in a transaction context.. As Paul had said:
".. if you don't see it, you should assume it as REQUIRED" ... so, 2 transactions context will be used!

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

Posted: Tue Apr 28, 2015 2:56 pm
by himaiMinh
If the client does not have a transaction context ...
There are two scenarios:
1. The client of XBean does not have a transaction context. But XBean 's regularM () is executed in a transaction by default. YBean's asyncM() executes in its own separate transaction. Therefore, there are only 2 transaction contexts, one is for regularM(), another one is for asyncM()

2. The client refers to XBean, maybe ? If XBean's regularM() has a transaction attribute NotSuppported, then, there is only one transaction context for asyncM().

In my opinion, we need to clarify who the client this option is refering to.

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

Posted: Tue Apr 28, 2015 8:06 pm
by admin
"If XBean's regularM() has a transaction attribute NotSuppported" cannot happen because the question clearly says< "In absence of any other deployment information or annotations related to these beans". Where there is no such information, then the transaction attributed is assumed to be Required.

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

Posted: Fri Jan 08, 2016 3:22 pm
by aazizi.tarik
This "In absence of any other deployment information or annotations related to these beans" doesn't mean that the bean is not a BMT, in that case there will be only one Tx context I guess

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

Posted: Sun Jan 10, 2016 8:44 am
by admin
As per section 13.3.1:
Typically enterprise beans will be specified to have container-managed transaction demarcation. This is the default if no transaction management type is specified.

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

Posted: Sun Jan 10, 2016 8:46 am
by aazizi.tarik
Ok, I thought "absence of any other deployment information or annotations" means that some annotation exist and we don't have the information. sorry its my english wich is bad

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

Posted: Mon May 29, 2017 11:49 pm
by johnlong
a new one is created for YBean also.
Where exactly does this new transaction demarcation start : in XBean.regularM() or in YBean.AsyncM?

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

Posted: Mon May 29, 2017 11:56 pm
by admin
The container starts a new one just before it invokes YBean.AsyncM method. It happens in container's code. Not in application code.

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

Posted: Tue May 30, 2017 11:08 am
by johnlong
I see, will this transaction cover any application code in this particular example?

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

Posted: Tue May 30, 2017 11:51 am
by admin
Yes, it will cover asycnM method.

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

Posted: Thu Jun 01, 2017 7:43 am
by johnlong
So transactional context will propagate into asycnM method and it will be new transaction as if RequiresNew transactional attribute specified on asyncM method?

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

Posted: Thu Jun 01, 2017 8:56 am
by admin
Yes, REQUIRED behaves like REQUIRES_NEW in case of asynchronous calls.