What two options describe what will happen when the create method is called within an application ‘ uses container managed transactions? (Choose two)

Given the following code:

Public void create () {
try {
doA () {
} catch (PersistenceException e) {}
try (doB) ();
} catch (PersistenceException e) {}
}

Calling method doA will cause an NonUniqueResultException to be thrown. Calling method doB will cause an EntityExistsException to be thrown.
What two options describe what will happen when the create method is called within an application ‘ uses container managed transactions? (Choose two)

Given the following code:

Public void create () {
try {
doA () {
} catch (PersistenceException e) {}
try (doB) ();
} catch (PersistenceException e) {}
}

Calling method doA will cause an NonUniqueResultException to be thrown. Calling method doB will cause an EntityExistsException to be thrown.
What two options describe what will happen when the create method is called within an application ‘ uses container managed transactions? (Choose two)

A.
Method doB will never be called.

B.
The current transaction will continue after doA executes.

C.
The current transaction will continue after doB executes.

D.
The current transaction will be marked for rollback when doA is called.

E.
The current transaction will be marked for rollback when doB is called.



Leave a Reply 10

Your email address will not be published. Required fields are marked *


Bruno Mathidios

Bruno Mathidios

B,E are correct: B because the exception is not an application exception.

Erkin

Erkin

CE Because NonUniqueResultException does not cause the provider to rollback transaction.

Amine Hakouna

Amine Hakouna

Correct

Lejmi

Lejmi

B,E
+ Note 1: the code above is not compilable.
–> Correct Syntax:
public void create() {
try {
doA();
} catch(PersistenceException e) {}
try {
doB();
} catch(PersistenceException e) {}
}

+ Note 2:
– doA() –> NonUniqueResultException (no rollback) –> transaction continues –> B correct
– doB() –> EntityExistsException (rollback) –> E correct

Lejmi

Lejmi

3.6.8 (Spec.)
==========
Runtime exceptions other than the NoResultException, NonUniqueResultException, QueryTimeoutException, and LockTimeoutException thrown by the methods of the Query and TypedQuery interfaces other than those methods specified below cause the current transaction to be marked for rollback.

On database platforms on which a query timeout causes transaction rollback, the persistence provider must throw the PersistenceException instead of the Query-TimeoutException.
Runtime exceptions thrown by the following methods of the Query and TypedQuery interfaces do not cause the current transaction to be marked for rollback: getParameters, getParameter, getParameterValue, getLockMode.
Runtime exceptions thrown by the methods of the Tuple, TupleElement, and Parameter interfaces do not cause the current transaction to be marked for rollback.

Anas

Anas

Are those questions still valid or not ?
Thank you

Tommy_Croatia_ZGB

Tommy_Croatia_ZGB

B,E