Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to obtaining an EntityManager inside a Stateless bean without anotation

843833Apr 27 2009 — edited May 8 2009
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 5 2009
Added on Apr 27 2009
1 comment
164 views