This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why bean managed transaction is not allowed with entity beans

 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BMT is not allowed in CMP beans, or is not allowed in entity beans at all?
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is not allowed in entity beans at all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic