How will the
EJB container handle exceptions thrown by a business method of a bean with container managed transaction demarcation? [Check all correct answers]
1. If the instance called setRollbackOnly(), the EJB container will rollback the transaction.
2. If the instance did not call setRollbackOnly(), the EJB container will commit the transaction.
3. The EJB container will throw a RemoteException.
4. If the bean represents an entity bean, it will remove the entity from the datasource.
5. If the bean represents a session bean, the bean will be removed from the pool.
ejbcertificate.com answers:1,2
My views:
1) This is OK , in both cases, App exceptions and System Exceptions, if bean calls setRollbackOnly , Tx will be rollbacked.
2)if Instance didn't call setRollbackOnly, which exception is it ...this decides for what container does....for App Exceptions, container doesn't rollback Tx nor does it commit, it allows Tx to be continued.
But if its Sys exception, Tx is rollbacked.
3) NO Gurentee
4)Database entry is not removed...!!!
5)If its session it will be removed from pool (i think talkin about discarding the instance..)..only if its Sys exception....
I selected 1,2, but since ques. is unclear about type of exception, I was wrong in the context of question.
Please correct me if necessary.
What do ya think?
Amol