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

Moderator: admin

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

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

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

ssoltanid
Posts: 3
Joined: Wed Nov 12, 2014 3:03 pm
Contact:

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

Post by ssoltanid »

I read this topic and the answer to the question.
could be asked This kind of question at the exam ?

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

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

Post by admin »

Yes, it is possible.
If you like our products and services, please help us by posting your review here.

renatumb
Posts: 47
Joined: Mon Apr 08, 2013 7:55 pm
Contact:

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

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

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

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

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

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

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

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

Post 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

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

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

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

Post 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

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

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

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

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

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

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

I see, will this transaction cover any application code in this particular example?

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

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

Post by admin »

Yes, it will cover asycnM method.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

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

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

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

Post by admin »

Yes, REQUIRED behaves like REQUIRES_NEW in case of asynchronous calls.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

Sorry for the off-topic. But I have another question about transaction propagation.
Excerpt from O'reilly EJB 3.1 book
If an EJB calls another EJB with a different transaction scope, the persistence context, regardless of whether it is extended, is not propagated.
I think this is wrong, as transaction shall propagate from BMT to CMT. Could you please clarify? Thank you.

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

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

Post by admin »

I am not sure in what context the book says that but you might want to talk to the author of the book about it.

It is true that Persistence context is propagated along with the transaction. But if two beans have different transaction attributes that require different transactions to be started, the persistence context cannot propagate.
You should also see Section 7.6.3 Persistence Context Propagation of JPA Specification.
HTH,
Paul
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 197
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong »

Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests