Page 1 of 1
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Sun Aug 07, 2011 5:42 pm
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!
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Wed Aug 10, 2011 5:53 am
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.
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Wed Aug 10, 2011 3:17 pm
by PedroKowalski
You're right.
I wrongly interpreted this question. Sorry for the misunderstanding and thank you for your answer
Cheers!
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Tue May 15, 2012 1:31 pm
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
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Wed May 16, 2012 8:16 pm
by admin
Yes, in that case the caller's transaction should be rolled back.
HTH,
Paul.
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Wed May 16, 2012 11:43 pm
by prakashyaji
admin wrote:Yes, in that case the caller's transaction should be rolled back.
HTH,
Paul.
Thank you for your clarification!
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Fri May 08, 2015 5:34 pm
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.
Re: About Question enthuware.oce-ejbd.v6.2.435 :
Posted: Fri May 08, 2015 7:14 pm
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.