I have installed EJB3.0RC1 - but I cannot find the entitymanager via jndi..
I do this:
ctx.lookup(unitName);
Where to look... ?
Peter
RC1 has these global JNDI definitions defined
java:/EntityManagers/<unit-name> -- Injected EM
java:/EntityManagerFactories/<unit-name> - Injected EMF
"donniedarko" wrote:
Yes I think I follow, and it solves again most of the issues i asume, but if I have not misunderstood your excellent examples I still would have to have
definitions of the enitity managers in the code like this one, wouldn't I?@PersistenceContext(name="em1", unitName="cust1DB")
What I really would like to do is to the declare the "linkage" to the enitymanagers defined in the persistence.xml's on the fly.
But maybe I can do that with your example by looking them up via JNDI since you are saying:
(if you don't specify a name() it is under the name of the field or setter method)
I.E I could declare just one "unnamed" entitymanager in the session bean@PersistenceContext EntityManager enitymanager;
???
And still use your concept ofprivate EntityManager getEntityManager(String unit) { String enc = org.jboss.ejb3.Container.ENC_CTX_NAME + "/env/" + unit; return (EntityManager)ctx.lookup(enc); }
getting the correct one? Is that possible?
My concern is that each time i register a new database and datasource (quite often in my case) I would have to edit the code in all the session beans and recompile my project and deploy.
I really want to be able to register new databases and datasources without having to change the code and recompile / deploy. Many of our customers have their own database, and having to add each new entitymanager in the code of virtually every session bean each time we get a new customer wouldn't really be a smooth operation.
Best regards
Jon Åkerström
http://www.lightminds.com
I'd like just to know how to use this Global JNDI. I dont find in the doc.
Because I have multiples databases and I'd like as donniedarko to avoid to recompile and deploy my application.
If I understood well, it is now possible to use the Global JNDI to load the EntityManagerS instead of using a MBean as donniedarko. but I'd like to know how to have multiple persistence.xml file in a archive .par in this case.
Moreover, I think I have still to have multiple -ds.xml file corresponding at my databases.
If you can explain me and show me a example code.
Regards.