This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
EJB2.0 Spec, Sect:17.1.2(p:332) "The Enterprise JavaBeans architecture supports flat transactions. A flat transaction cannot have any child (nested) transactions. Note: The decision not to support nested transactions allows vendors of existing transaction processing and database management systems to incorporate support for Enterprise Java- Beans. If these vendors provide support for nested transactions in the future, Enterprise Java- Beans may be enhanced to take advantage of nested transactions." Please correct me if I am wrong. Nested transactions are supported used in EJBs. Aren't they? (RequiresNew attribute etc...)
Cheers Ko Ko, I found the foll. response. "EJB does not support nested transaction it support only flat transaction.if u try to start a new transaction under a running transaction then it will throw IllegalStateException.If u r using declarative transaction with "RequiresNew" and for every function it will start a new transaction but it will suspend the exsiting running transaction.u can not run mutiple transaction concurrently." Perhaps it is just the wordings and the interpretation. If you start a new transaction under a running transaction or a suspended transaction, it is a nested transaction. Isn't it?
Ko Ko Naing
Joined: Jun 08, 2002
Originally posted by Vish Kumar: Cheers Ko Ko, I found the foll. response. Perhaps it is just the wordings and the interpretation. If you start a new transaction under a running transaction or a suspended transaction, it is a nested transaction. Isn't it?
Howdy -- if a transaction begins within the context of another *active* transaction, you would have a 'nested' transaction (which as you know is not allowed in EJB). In other words, if you start transaction A, and then start transaction B, without ending transaction A, then you have a nested transaction, where transaction A and B might affect one another. For example, if A rolls back, what happens to its child transaction B? And if B rolls back, what should happen to its parent transaction A? These issues are avoided in EJB, because you can have only FLAT transactions, where two different transactions do not have direct affect on one another. You CAN have more than one transaction underway, in the case of "RequiresNew" or when a BMT bean begins a transaction, but in both of those cases, the caller's transaction is SUSPENDED. In other words, the caller's transaction STOPS being the active transaction context, and has nothing to do with the new transaction. The caller's suspended transaction simply picks up again when the method it called is popped off the stack and it moves on to its next step... So with EJB flat transactions, there is never more than ONE transaction that is *active*, so no two transactions are ever related to one another. One transaction must END, or be SUSPENDED, before another begins. The Container will automatically suspend a transaction if the called method has a transaction attribute of RequiresNew, or if the bean is a BMT bean. Remember, BMT beans will NEVER use an incoming transaction context from the caller. BMT beans can run in ONLY their own transactions. cheers, Kathy