-
1. Re: how to get EntityManagerFactory in seam??
michaelcourcy Aug 18, 2008 12:36 PM (in response to deanhiller2000)You can do that using injection :
@PersistenceUnit(unitName="myPersistenceUnit") EntityManagerFactory myFactory;
In this situation make sure your persitence context join the current transaction by annotating your method.
@TransactionnalAttribute(TransactionnalAttributeType.REQUIRED) public void myFooMethod(){ EntityManager em = myFactory.createEntityManager(); ... }
Just curious : why not using the normal persitence context injection ?
@PersistenceContext EntityManager em;
-
2. Re: how to get EntityManagerFactory in seam??
deanhiller2000 Aug 19, 2008 12:11 AM (in response to deanhiller2000)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.