Exam 1z0-900 All QuestionsBrowse all questions from this exam
Question 16

Given:

If an exception is thrown inside the if block, what effect will it have on the transaction?

    Correct Answer: A

    The transaction attribute in use is TransactionAttributeType.REQUIRED, which means that if there is an existing transaction, the method will execute within that transaction, otherwise a new transaction will be started. In Enterprise Java Beans (EJB), only unchecked exceptions (runtime exceptions) and system exceptions cause the container to automatically roll back the transaction. Since AppException extends Exception (and not RuntimeException), it is a checked exception and will not cause an automatic rollback. Therefore, the transaction will be committed even if AppException is thrown.

Discussion
devmsalehOption: A

Answer is : A Transaction roll back if the thrown exception in unchecked exception, otherwise it will be committed although exception is raised.

orjavaOption: A

Answer: A... only roll back with unchecked exception