i don�t understand the spec point in page 372(18.2.1:Application exceptions)...
The Bean Provider is responsible for throwing the appropriate application exception from the business method to report a business logic exception to the client. Because the application exception does not automatically result in marking the transaction for rollback, the Bean Provider must do one of the following
to ensure data integrity before throwing an application exception from an enterprise bean instance: � Ensure that the instance is in a state such ..... � Mark the transaction for rollback using the EJBContext.setRollbackOnly() method
why i mut mark the transaction for rollback?... if i though one application exception should not rollback a transaction.
by the way...
why do i must declare a application exception (like a FinderException) in a bussines method into a bean class if i can handle it, or why do i must re-throw it, when i handled by a try/catch block?
Howdy -- I think in this case the spec is saying something like:
* When you throw an application exception, only YOU can decide if that exception can still allow the transaction to continue successfully, or if the transaction must be rolled back.
* IF you decide that the transaction must be rolled back, YOU must invoke setRollbackOnly(), because the Container does not roll transactions back for application exceptions (since it gives you--the bean provider--the choice).
So you do not have to mark the transaction for rollback unless you decide that the transaction should not complete successfully.
You do not have to rethrow an exception that you handle... only those that you decide you cannot recover from. Some exceptions must be defined because the Container may choose to subclass your bean class, and the subclass must be allowed to throw those exceptions to the Container, but it depends on the scenario and bean type, etc....