Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

What are flat transactions?

 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...)
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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!!!
 
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at Roman's EJB 2.0 ( get your free pdf copy ) he defines the terminology of nested and flat transactions.
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic