Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why cannot we have a BMT in an Entity Bean

 
Rahil Hurzuk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

So far from my reading of EJB I have gathered that we cannot use a Bean Managed Transaction (BMT) with Entity Beans & Entity Beans strictly have to be CMT

Can someone explain why it has to be that way i.e . Why cannot we have Entity beans with BMT

Rgrds
Rahil
 
Paymon Asadinia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

From what I understand the way that Entity Beans stay in sync with underlying datastores(i.e. a database), is via couple of the Container Callbacks namely ejbLoad() and ejbStore(). One can be sure that the container always calls ejbLoad after each ejbActivate(), and ejbStore after
each ejbPassivate(), based on the spec, container may call the two mentioned callbacks at any other time or in any order for that matter.
Now lets say that you'd want to have an Entity Bean with BMT demarcation, You'd put your code into ejbLaod() callback method, perhaps around JDBC code. Since there is no guarantee that ejbLoad() will be called when you'd expect it to, your TX may never complete. This is why it is illegal to have bean managed transaction with Entity Beans.

SCJP (2)
SCWCD
SCBCD (In Progress)



 
no wonder he is so sad, he hasn't seen this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!