users@glassfish.java.net

Dynamic persistence unit name

From: <forums_at_java.net>
Date: Fri, 14 Sep 2012 09:25:38 -0500 (CDT)

Hello, I'd like to know if it's possible to inject from a custom resource,
the persistence unit name into EJB's. I'd like to do something like this :
@Resource(name="my_jndi_name") public static String myPUName; and then
@PersistenceContext(unitName = myPUName) protected EntityManager em; The
problem is I need to give a constant to the unitName attribute, so I can't do
this. Actually, I'd like to use a different unit in the development process
than in the production one, without taking the risk to forget to change the
persistence unit name before deploying. Maybe in spite of injecting an
EntityManager I could inject en EntityManagerFactory, but it seems a bit more
consuming. Any suggestions ? Thanks a lot.

--
[Message sent by forum member 'laps']
View Post: http://forums.java.net/node/890250