Originally posted by Along huang:
Here are two problem confusing me:
1. How can I know a exception is System exception or Application exception? As ObjectNotFoundException, I really don't know it belong to which type.
2. In a transaction, does it really not roll back automatically when meeting a application exception? what happen when it meeting a SQL exception that is defind by developer(such as a exception included in store procedure)?
best regards
(a) EJBException is a system exception and I would say all child classes of EJBException would fall under that category
(b) SQLException extends from Exception class. It is not a system exception and therefore it will not do the automatic rollback of the transaction when executing under an
EJB Container. If you want to rollback the transaction then you will have to:
1. Either explicitly get the ejb context and call setRollBackOnly() method to notify the EJB container about the rollback.
2. OR translate the SQLException into an EJBException. This way you are converting an application exception into a system exception, which would cause the rollback.