[jboss-user] [JBoss Seam] - Re: ManagedPersistenceContext in Manning JPA book

Delphi's Ghost do-not-reply at jboss.com
Fri Nov 9 10:39:39 EST 2007


My understanding of it is that :

@PersistenceContext (EJB PC) - Single shot persistence context for the duration of the method call

@PersistenceContext(Type=EXTENDED) (Extended EJB PC) - Persistence context that lasts for the duration of the session bean, but not shareable across session beans.

@In private EntityManager entityManager (SMPC) - Seam Managed Persistence Context that is tied to the conversation and can be used in multiple method calls, and across multiple beans. As amitev mentions, you get a lot of extras for free with the SMPC.

The SMPC also gets rid of lazy initialization errors by using two transactions on a request. One to commit the work, and then another to let you read database entities when rendering the view if you use the Seam transactional phase listener.

If you are working in a Seam-Gen generated app, you should be ready to start using SMPCs already without requiring any tweaking with the config.

You use SMPCs in your beans by injecting the entityManager using the following : 



  | @In
  | private EntityManager entityManager;
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4103295#4103295

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4103295



More information about the jboss-user mailing list