Given:
Bean A with transaction attributes of "RequiresNew" for all its methods.
Bean B with transaction attributes of "Supports" for all its methods.
A client having a transaction context calls a method mA() on bean A, which in turns calls a method mB() on Bean B.
Assuming all invocations are local, which of the following statements is correct if mB() encounters a system exception?
Select 3 options
1. The client's transaction will be marked for roll back.
2. The client will get a javax.ejb.EJBException but it can continue with the same transaction.
3. The client will get a javax.ejb.EJBTransactionRolledbackException
4. The bean B instance will be discarded.
5. The bean A instance will NOT be discarded.
6. Changes made to the database by mA(), will be commited.
2 : Since mA() encounters a system exception (thrown by mB()), it will translate to EJBException for the client. However, the client's transaction will not be rolled back because of the above mentioned reason.
4 : Because it encounters a system exception.
5 : Since mB() executes within mA()'s transaction context, the container will mark it for rollback and throw javax.ejb.EJBTransactionRolledbackException to mA() when mB() encounters a system exception.
5. The bean A instance will NOT be discarded.
SCJP 5 (98%) - SCBCD 5 (98%)
1. The client's transaction will be marked for roll back.
2. The client will get a javax.ejb.EJBException but it can continue with the same transaction.
3. The client will get a javax.ejb.EJBTransactionRolledbackException
4. The bean B instance will be discarded.
5. mA() will get a javax.ejb.EJBTransactionRolledbackException
6. The bean A instance will NOT be discarded.
7. Changes made to the database by mA(), will be commited.
I agree if the client doesn't catch the EJBException. If the client catches it, enthuware's solution is correct.But what Im arguing is Client gets javax.ejb.EJBException (System Exception),
1. So client will be discarded, Therefore client can't continue same transaction.
2. Also its transaction will be marked for rolled back (because it get a system exception).
Hence I think correct answers should be 1, 4 and 5
SCJP 5 (98%) - SCBCD 5 (98%)
Either client catch exception, transaction already marked for rolledback
SCJP 5 (98%) - SCBCD 5 (98%)
Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Pay attention! Tiny ad!
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|