Dynamic persistence unit name
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 :
public static String myPUName;
@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.