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

Moderator: admin

Post Reply
deadlock_gr
Posts: 54
Joined: Tue Apr 19, 2011 10:32 am
Contact:

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

Post by deadlock_gr » Wed Apr 20, 2011 8:16 am

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.

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

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

Post by admin » Wed Apr 20, 2011 3:11 pm

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

deadlock_gr
Posts: 54
Joined: Tue Apr 19, 2011 10:32 am
Contact:

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

Post by deadlock_gr » Thu Apr 21, 2011 3:22 am

You're right, thanks!

costin1989
Posts: 15
Joined: Tue Apr 21, 2015 1:36 am
Contact:

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

Post by costin1989 » Sat Mar 19, 2016 3:43 am

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.

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

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

Post by admin » Sat Mar 19, 2016 9:17 pm

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

costin1989
Posts: 15
Joined: Tue Apr 21, 2015 1:36 am
Contact:

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

Post by costin1989 » Sun Mar 20, 2016 4:27 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests