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

Moderator: admin

Post Reply
PedroKowalski
Posts: 25
Joined: Thu Aug 04, 2011 10:36 am
Contact:

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

Post by PedroKowalski »

Howdy!

I've got some objections about the third answer (correct).
Bean1 calls EJBContext.getRollbackOnly() and gets true.
There is no information about the transaction attribute. If this means that I should assume that default attribute REQUIRED is used, than fine - this answer is correct.

But if i.e. REQUIRES_NEW is used, than the Bean 1 will get 'false' value, but the Bean 2 transaction was rolled back.

What do you think about that?

Thanks in advance,

Cheers!

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

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

Post by admin »

I don't think it matters what the transaction attribute is in this case. Because even in case of REQUIRES_NEW, if Bean1 calls EJBContext.getRollbackOnly() and gets true, there is no point in continuing with the transaction. EJBContext.getRollbackOnly() gives you the status of b1's transaction. Whether that transaction is same as the one used for b2, is irrelevant. b1's transaction (if it is different from b2) could be set to roll back only for other reasons too.

PedroKowalski
Posts: 25
Joined: Thu Aug 04, 2011 10:36 am
Contact:

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

Post by PedroKowalski »

You're right.

I wrongly interpreted this question. Sorry for the misunderstanding and thank you for your answer :-)

Cheers!

prakashyaji
Posts: 25
Joined: Sun May 13, 2012 1:39 am
Contact:

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

Post by prakashyaji »

In explanation of option 2:
Note that EJBException (or RemoteException for remote clients) is thrown to the caller bean when the callee bean executes without a transaction context (this case may happen with the NotSupported, Never, and Supports attributes for the callee bean) or a new transaction context and throws a system exception.

If the client executes in a transaction, the client’s transaction may or may not be marked for rollback.

-----------------------------------------------------------------------------------

In context of this question, if callee bean method uses "Supports" then, caller bean's transaction will be rolled back. Because caller bean has started a transaction and callee supports it.

Please let me know if I am confused...

regards,
Prakash yaji
Last edited by prakashyaji on Wed May 16, 2012 11:43 pm, edited 1 time in total.

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

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

Post by admin »

Yes, in that case the caller's transaction should be rolled back.

HTH,
Paul.

prakashyaji
Posts: 25
Joined: Sun May 13, 2012 1:39 am
Contact:

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

Post by prakashyaji »

admin wrote:Yes, in that case the caller's transaction should be rolled back.

HTH,
Paul.
Thank you for your clarification!

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

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

Post by himaiMinh »

Even though the question mentions that bean 1 and bean2 are running with CMT, but it does not say what transaction attribute of m1(). If the transaction attribute of m1 is SUPPORTS, NOT_SUPPORTED or NEVER, calling EJBContext.getRollbackOnly() will throw illegalStateException.

I assume m1()'s transaction attribute is REQUIRED, but not SUPPORTS in this question.

Reference : 13.6.2.9 of JSR 318.

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

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

Post by admin »

Well, the question does mention that there is a transaction. SO the transaction attribute cannot be NOT_SUPPORTED or NEVER. So I don't think IllegalStateException is a possibility here.
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests