1 Reply Latest reply on Apr 13, 2008 6:14 PM by Pete Muir

    SMPC and @In EM injection

    Guillaume Jeudy Master

      Hi,


      I am using SMPC (Seam Managed Persistence Context) by injecting an entityManager using @In annotation. I have a few questions that I guess could be verified through testing but I just want to make sure by consulting Seam experts opinions.


      1./ What is the scope of the SMPC? Does it last as long as the scope of the SFSB that initiated it ? If that is consistent with EJB3 PC I would guess yes.


      2./ If I use SMPC entityManager in SLSBs only do I still have to inject an entityManager in my SFSB to ensure the SMPC is 'initialized' ? The usual pattern I have is a Conversation scoped SFSB managing a usecase and issuing calls to re-usable Stateless scoped SLSBs for persistence related operations. In practice I don't need the entityManager in my SFSBs but I'm not sure if I should still inject it using @In to make sure the SMPC is bound(scoped) to my SFSB.
      Right now I'm injecting the EM in both SFSBs and SLSBs for safety purposes.


      Any insights appreciated.


      Thanks,
      -Guillaume

        • 1. Re: SMPC and @In EM injection
          Pete Muir Master

          Guillaume Jeudy wrote on Apr 10, 2008 02:43 PM:


          Hi,

          I am using SMPC (Seam Managed Persistence Context) by injecting an entityManager using @In annotation. I have a few questions that I guess could be verified through testing but I just want to make sure by consulting Seam experts opinions.


          Or by reading the reference manual. Or by reading the forum.



          1./ What is the scope of the SMPC? Does it last as long as the scope of the SFSB that initiated it ? If that is consistent with EJB3 PC I would guess yes.

          The conversation.



          2./ If I use SMPC entityManager in SLSBs only do I still have to inject an entityManager in my SFSB to ensure the SMPC is 'initialized' ? The usual pattern I have is a Conversation scoped SFSB managing a usecase and issuing calls to re-usable Stateless scoped SLSBs for persistence related operations. In practice I don't need the entityManager in my SFSBs but I'm not sure if I should still inject it using @In to make sure the SMPC is bound(scoped) to my SFSB.
          Right now I'm injecting the EM in both SFSBs and SLSBs for safety purposes.

          No, as the SMPC is scoped to the conversation, the complex PC propagation rules from EJB3 don't apply.