5 Replies Latest reply on Dec 3, 2007 6:02 PM by Pete Muir

    ManagedPersistenceContext in Manning JPA book

    Arbi Sookazian Master

      The last chapter on Seam in the JPA with Hibernate book was very informative. I stumbled upon the section on triggering a LazyInitializationException when trying to root-cause analyze a colleague's LazyInitializationException problem.

      So it turns out that you can fix this problem by extending the persistence context as follows in your SFSB:

      @PersistenceContext(type=EXTENDED)
      private EntityManager em;


      When I search for keyword "ManagedPersistenceContext" in all of the Seam example apps in the CR2 distro, I got no hits. Does that mean it's not necessary to use the Seam managed context and the TransactionalSeamPhaseListener to solve LazyInitializationException's?

      When do you need to integrate the Seam-managed persistence context as explained in pages 814-815 of the book? I guess I'm not understanding exactly the added value of using the Seam-managed persistence context versus javax.persistence.PersistenceContext.

      I see more methods in the API for the Seam-managed persistence context class...