Given:
If an exception is thrown inside the if block, what effect will it have on the transaction?
Given:
If an exception is thrown inside the if block, what effect will it have on the transaction?
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.
Answer is : A Transaction roll back if the thrown exception in unchecked exception, otherwise it will be committed although exception is raised.
Answer: A... only roll back with unchecked exception