GeeCON Prague 2014*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Difference between transaction and extended persistence context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Difference between transaction and extended persistence context" Watch "Difference between transaction and extended persistence context" New topic
Author

Difference between transaction and extended persistence context

bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45

Hi,

I am very confused about difference between beanmanaged and container managed transactions.

How the persistense context relate with bean managed and container managed transactions?

what is the difference between transaction and extended persistence context?

how these two relate with container and bean managed transaction?

Please help in this.I am confused with all these terms.


Please help me.


Thanks
Bhaskar
Aitch Chung
Greenhorn

Joined: Apr 26, 2010
Posts: 5
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.
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45


Thanks a lot. your explanation is good

Thanks
Bhaskar
 
GeeCON Prague 2014
 
subject: Difference between transaction and extended persistence context