[jboss-user] [Persistence] - Re: How to get an EntityManager or EntityManagerFactory usin

Marcos_APS do-not-reply at jboss.com
Fri Oct 2 12:59:28 EDT 2009


"PeterJ" wrote : You can use the JNVIView mbean to see all of the names in JNDI.
  | http://www.jboss.org/community/wiki/DisplayTheJNDITreeWithTheJMXConsole
  | 

I have done some research on this topic and I had to do this to get an EntityManagerFactory using JNDI:

In my persistence.xml:


  | <properties>
  |     <property name="jboss.entity.manager.factory.jndi.name" value="java:/persistence/solicitacoes" />
  | </properties>
  | 

Now I can use the code:


  | EntityManagerFactory emf = (EntityManagerFactory) new InitialContext().lookup(
  |     "java:/persistence/solicitacoes");
  | EntityManager em = emf.createEntityManager();
  | 

Is this the "official" way or is there a simple one?

Marcos

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4258463#4258463

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4258463



More information about the jboss-user mailing list