1Z0-898 · Question #33
Given the following code: Public void create () { try { doA () { } catch (PersistenceException e) {} try (doB) (); } catch (PersistenceException e) {} } Calling method doA will cause an…
The correct answer is B. The current transaction will continue after doA executes. E. The current transaction will be marked for rollback when doB is called. B: PersistenceExceptionis thrown by the persistence provider when a problem occurs. All instances of PersistenceException except for instances of NoResultException, NonUniqueResultException, LockTimeoutException, and QueryTimeoutException will cause the current transaction, if…
Question
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)
Options
- AMethod doB will never be called.
- BThe current transaction will continue after doA executes.
- CThe current transaction will continue after doB executes.
- DThe current transaction will be marked for rollback when doA is called.
- EThe current transaction will be marked for rollback when doB is called.
How the community answered
(24 responses)- A4% (1)
- B79% (19)
- C13% (3)
- D4% (1)
Explanation
B: PersistenceExceptionis thrown by the persistence provider when a problem occurs. All instances of PersistenceException except for instances of NoResultException, NonUniqueResultException, LockTimeoutException, and QueryTimeoutException will cause the current transaction, if one is active, to be marked for rollback. E: EntityExistsException is thrown by the persistence provider when EntityManager.persist(Object) is called and the entity already exists. The current transaction, if one is active, will be marked for rollback.
Topics
Community Discussion
No community discussion yet for this question.