This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Why bean managed transaction is not allowed with entity beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Why bean managed transaction is not allowed with entity beans" Watch "Why bean managed transaction is not allowed with entity beans" New topic
Author

Why bean managed transaction is not allowed with entity beans

Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
I know that many people want to know the exact answer to the question "why BMT is not allowed with entity beans?". The answer was made clear to me after I reviewed Mastering EJB 3rd Edition by Ed Roman (pg 315). In a nutshell it is like this: in order to start a transaction the container calls ejbLoad() to acquire the locking and get the last copy of data from the database. Finally the container calls ejbStore() in order to update the database and commit the transaction. The point is that allowing the bean to start the transaction then this should happen inside of ejbLoad() (before acquiring the db lock) and it should be committed inside of ejbStore() (before releasing the lock). This implies that the container will call ejbLoad() and ejbStore() only once and exactly in this order. This actually doesn’t happen all the time and is possible that ejbStore() doesn’t get called at the end of the transaction (some container choose to cache the data between transactions). In this case one might get in a terrible situation when the transaction gets never committed.


I think, therefore I exist -- Rene Descartes
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
BMT is not allowed in CMP beans, or is not allowed in entity beans at all?


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Is not allowed in entity beans at all.
 
Consider Paul's rocket mass heater.
 
subject: Why bean managed transaction is not allowed with entity beans
 
Similar Threads
A basic Question on ejbLoad and ejbStore
BMT with Entity beans
Search for Entity beans
Bean managed Transaction for Entity Beans
why entity bean cannot manage own transtaction while session beans can do this ?