This content has been marked as final.
Show 3 replies
-
1. Re: Acces EntityManager from outside of ejb beans(Custome JS
pmuir Jun 27, 2006 4:52 AM (in response to holgerprause)You can look up the entity manager in JNDI. In persistence.xml ensure that the EntityManager is registered in JNDI:
<property name="jboss.entity.manager.jndi.name" value="java:/EntityManager" />
and then look it up in JNDI in the validator.
Alternatively you can use Component.newInstance("...") to get a Seam Managed PC (but I'm not sure this is supported). -
2. Re: Acces EntityManager from outside of ejb beans(Custome JS
jtucker Jun 27, 2006 4:52 AM (in response to holgerprause)Just grab the EntityManagerFactory from JNDI.
Make sure you have a line like this in persistence.xml to specify where the EMF is stored...<property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagerFactories/bookingDatabase" />
And use this code to get the EMF and create the EntityManager...Hashtable<String, String> env = new Hashtable<String, String>(); env.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory"); env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); Context ctx = new InitialContext(env); EntityManagerFactory emf = (EntityManagerFactory) ctx.lookup("java:/EntityManagerFactories/bookingDatabase"); EntityManager em = emf.createEntityManager();
-
3. Re: Acces EntityManager from outside of ejb beans(Custome JS
holgerprause Jun 27, 2006 8:15 AM (in response to holgerprause)Hello,
Thank u very much u both, it works :-)
You helped me a lot, i must say i am working with seam for now 5 days and until now, i really have fun, but lets see what challenges ill encounter in future regarding seam ^^
Thank u again,
Bye,
Holger