I just read the Transactions Chapter (10) of "Mastering EJB 3.0" and now I'm confused about nested transactions.
The book says
"The EJB-defined transaction manager does not support nested transactions; it requires support for only flat transactions." (Site 278, Note)
This fact is described not only by this book, I found this statement in other books / websites.
But if I call a "Requires New" annotated Method from a, let's say "Required" annotated Methode, what I have is a nested transaction, isn't it? I can roll back the inner transaction or commit it, without affecting the outer transaction. And if I want the outer Transaction to be aborted, I throw an EJBException back and the whole transaction will be rolled back.
So is it just that this behavior is not required by the EJB 3.0 specification or have i misunderstood something? I just can't get the difference between nested transactions and the described behavior.
Regards Norman
RequiresNew does not create a nested transaction because the first transaction is suspended while the second transaction is running. A nested transaction looks like this:
Instead, RequiresNew looks like this: