File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes What are flat transactions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "What are flat transactions?" Watch "What are flat transactions?" New topic
Author

What are flat transactions?

Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
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...)
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
You might want to view the following thread in Sun Developer Network Forum, in which they discuss about the EJB and nested transactions
http://forum.java.sun.com/thread.jsp?forum=35&thread=446588&tstart=0&trange=15


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
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
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
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?

U get the idea, ah? Cheers too!!!
Rufus BugleWeed
Ranch Hand

Joined: Feb 22, 2002
Posts: 1551
If you look at Roman's EJB 2.0 ( get your free pdf copy ) he defines the terminology of nested and flat transactions.
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What are flat transactions?
 
Similar Threads
Nested transactions
Question on EJB Transactions
Yet another dumb question
Allow single transaction only
Nested Transaction in EJB 3.0