2 Replies Latest reply on Aug 19, 2008 12:11 AM by Dean Hiller

    how to get EntityManagerFactory in seam??

    Dean Hiller Expert

      My web application is starting a telecom application and the telecom app has it's own sessions for outgoing and incoming calls and it's own framework(though not as good as seams).  Anyways, I need to give that sub application the EntityManagerFactory so it can create EntityManagers for each incoming or outgoing call and that EntityManager lasts for the whole phone call(ie. long conversation). 

      anyways, how do I inject the EntityManagerFactory into my seam bean which gives it to this subapplication.

        • 1. Re: how to get EntityManagerFactory in seam??
          Michael Courcy Newbie

          You can do that using injection :

          EntityManagerFactory myFactory;

          In this situation make sure your persitence context join the current transaction by annotating your method.

          public void myFooMethod(){
              EntityManager em = myFactory.createEntityManager();

          Just curious : why not using the normal persitence context injection ?

          EntityManager em;

          • 2. Re: how to get EntityManagerFactory in seam??
            Dean Hiller Expert

            I do inject the EntityManager for all my web beans.  My problem is when i have a phone call come in to that subsystem I talked about.  Seam is not going to help me there at all as it won't create an EntityManager for me!!!  Instead, when a phone call comes in, I have a statemachine and before I fire into that statemachine, I start the transaction.  Also, I plan on trying out the long running transaction as well as it starts with the user calling in and ends with the user hanging up or us hanging up on the user(after a bye message is played of course :) ).
            make sense?

            yes, I wish seam sat above my telephony code but right now it is only built to sit below JSF :(.  I almost want to do something similar but don't have the time.