5 Replies Latest reply on Feb 27, 2012 6:44 AM by hantsy

    EntityManager from long running conversation injected in RequestScoped bean without propagation

    miguelzp

      What a strange thing using Seam managed persistence:

       

      I. Producer.java

       

          @ExtensionManaged

          @Produces

          @PersistenceUnit(unitName="db")

          @ConversationScoped

          EntityManagerFactory emf;

       

       

      II. Managed Bean 1:

       

      @ConversationScoped

      public class Bean1 ...

       

      ...

          @Inject

          private EntityManager entityManager;

      ...

       

       

      III. Simple href without params clicked during long running conversation with Bean1 implicated

       

      <h:outputLink value="page2.xhtml" target="_blank">

                              <h:outputText value="Go" />

      </h:outputLink>

       

       

      IV. Managed Bean 2 with method called by s:viewAction in page2.xhtml:

       

      @RequestScoped

      public class Bean2 ...

       

           @Inject

          private EntityManager entityManager;

       

       

       

      --> EntityManager injected in Bean2 is the same instance as in Bean1 without any cid param, cookie etc. that could propagate the conversation (I checked the http)

       

      How could this behaviour be explained?

       

      How can I force a new EntityManager (PC) instance for each request in Bean2?

       

      Miguel