An
EJB business method performs an operation that throws a checked exception. The bean cannot
recover from this checked exception and should rollback. The bean will be deployed using
container-managed transaction demarcation. Which implementation is the BEST?
A. public void businessMethod() { try { // operation throwing SomeCheckedException goes here }
catch (SomeCheckedException ae) { throw new EJBException(ae); } }
B. public void businessMethod() { try { // operation throwing SomeCheckedException goes here }
catch (SomeCheckedException ae) { context.setRollbackOnly(); throw new EJBException(ae); } }
C. public void businessMethod() throws EJBException { try { // operation throwing
SomeCheckedException goes here } catch (SomeCheckedException ae) { throw new EJBException(ae); }
}
D. public void businessMethod() throws EJBException { try { // operation throwing
SomeCheckedException goes here } catch (SomeCheckedException ae) { context.setRollbackOnly();
throw new EJBException(ae); } } }}