How to obtaining an EntityManager inside a Stateless bean without anotation
843833Apr 27 2009 — edited May 8 2009Hi,
i work on glassfih, i usualy use a persistence unit in my persistence.xml file and i use the @PersistenceContext(name="myPU") to inject ressource in my em.
I use stateless to provide remote methods to CRUD my entity beans.
But, in my new project, i have 4 peristence units, and i would like to know the best way to dynamically set my em in my stateless bean code...???
I have a book about jpa, it seems, on jboss, we can lookup the em into the jndi. I tried this on glassfish but it fails.
I tried "emf=Persistence.createEntityManagerFactory("myPU");" and i call the "EntityManagerCreate"... when i try to persist a entity bean, i don't know what happens, i only have some toplink warning in my server logs, about some drop on unexisting tables, so all seems ok about the persist call but in my DB, there is no data inserted.
I hope someone can help me . Thanks in advance.
Seb.
Edited by: SebV on Apr 27, 2009 12:53 PM