1Z0-895 · Question #85
While excepting a business method in a stateless session bean the container rolls back the method's transaction. Which three are possible causes for the container's behavior? (Choose three.)
The correct answer is A. The bean uses container-managed transactions and invokes EJBContext.setRollbackOnly. D. The business method throws a checked exception of a class type that is marked with the F. The bean uses container-managed transactions and throws a checked exception of a class type that is. A:setRollbackOnly Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction marked for rollback can never commit. Only enterprise beans with container-managed transactions are allowed to use this method. In a stateless…
Question
Options
- AThe bean uses container-managed transactions and invokes EJBContext.setRollbackOnly.
- BThe bean uses container-managed transactions and invokes EJBContext.getRollbackOnly.
- CThe business method throws a java.lang.NullPointerException.
- DThe business method throws a checked exception of a class type that is marked with the
- EThe business method throws a unchecked exception of a class type that is marked with the
- FThe bean uses container-managed transactions and throws a checked exception of a class type that is
How the community answered
(16 responses)- A75% (12)
- B13% (2)
- C6% (1)
- E6% (1)
Explanation
A:setRollbackOnly Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction marked for rollback can never commit. Only enterprise beans with container-managed transactions are allowed to use this method. * In a stateless session bean with bean-managed transactions, a business method must commit or roll back a transaction before returning. *Bean-Managed Transactions In bean-managed transaction demarcation, the code in the session or message-driven bean explicitly marks the boundaries of the transaction. Although beans with container-managed transactions require less coding, they have one limitation: When a method is executing, it can be associated with either a single transaction or no transaction at all. If this limitation will make coding your bean difficult, you should consider using bean-managed * (incorrect)Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time. B:getRollbackOnly Test if the transaction has been marked for rollback only. An enterprise bean instance can use this operation, for example, to test after an exception has been caught, whether it is fruitless to continue computation on behalf of the current transaction. Only enterprise beans with containermanaged transactions are allowed to use this method.
Topics
Community Discussion
No community discussion yet for this question.