Page 1 of 1

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

Posted: Wed Apr 20, 2011 8:16 am
by deadlock_gr
In the following:
In this case, since you are asked only to fail the checkout and not rollback the transaction, you can do one of the following -
1. Do not call setRollbackOnly() and throw a checked application exception. For example, throw new InvalidCartItemException(), where InvalidCartItemException is a normal checked exception.
2. Do not call setRollbackOnly() and throw an unchecked application exception that is not marked with rollback=true.
I think that 2. is wrong. If an unchecked exception is thrown, it is considered a System Exception, which result in transaction rollback. The only unchecked exceptions that do not cause rollback are the ones annotated as @ApplicationException(rollback=false).

So, I think it should be:

2. Do not call setRollbackOnly() and throw an unchecked application exception which is annotated as @ApplicationException with rollback=false.

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

Posted: Wed Apr 20, 2011 3:11 pm
by admin
I think the given answer is correct because it says "unchecked application exception" and not just unchecked exception, which as you rightly pointed out would be considered a system exception.

In other words, unchecked exceptions that are annotated with @ApplicationException are called unchecked application exceptions.

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

Posted: Thu Apr 21, 2011 3:22 am
by deadlock_gr
You're right, thanks!

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

Posted: Sat Mar 19, 2016 3:43 am
by costin1989
I didn't get the explication here:

if you annotate an unchecked exception with @ApplicationException(rollback=true) then the transaction will be rolledback which is not the desired behavior.

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

Posted: Sat Mar 19, 2016 9:17 pm
by admin
costin1989 wrote:I didn't get the explication here:
Can you please tell me which part did you not get so that I can elaborate on it?
if you annotate an unchecked exception with @ApplicationException(rollback=true) then the transaction will be rolledback which is not the desired behavior.
That is why the correct answer is, "Throw an unchecked application exception that is marked with rollback=false".

HTH,
Paul.

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

Posted: Sun Mar 20, 2016 4:27 am
by costin1989
"2. Do not call setRollbackOnly() and throw an unchecked application exception that is not marked with rollback=true. "

i didn't read correct this statement (i haven't seen "NOT")

please excuse me!