• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Why bean managed transaction is not allowed with entity beans

 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is not allowed in entity beans at all.
 
Dinner will be steamed monkey heads with a side of tiny ads.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic