Hi..
System exception is something which cannot be recovered, so the continer will rollback the transaction. Container views application exceptions as an abnormal application-level condition, which typically can be recovered. So the container will not rollback the transaction, it tries commit...
So in such cases,
you should explicitly mark the transaction for rollback using EjbContext.setRollbackOnly() method. Your code would look like this:
try {
// ---- do your db ops ---
} catch (SQLException e) {
// Mark the transaction for rollback..
sessionCtx.setRollbackOnly();
// If you want throw some appliation exception here..
throw new NotEnoughBalanceException();
}
- holla