posted 13 years ago
Hi,
The bean managed transaction(a.k.a. BMT) let you do the transaction yourself, like, defining the demarcation of the transaction, when to commit and when to set rollback etc. The container managed tranaction let the container do the lifting.
Usual case of using persistence service provided by the container is let the container decide when to persist entities related. When the method returned, the tranaction ended also. Hence, the states of entities persisted to the db. In this case the beginning and end of the method defines the persistence scope. If you're using stateful session bean, client might go through many different methods which may need the data from method to method. Therefore, the demarcation limited to the method might not be applied. The extended scope for peresistence context can keep the entity manger from being destroied when the client goes through the methods, hence, for the following case:
Usual Persistence Context:
Exteneded Persistence Context:
I hope it helps.