This content has been marked as final.
Show 2 replies
-
1. Re: Looking up a PU from @PersistenceContext annotation
pmuir Jan 7, 2009 12:37 PM (in response to pmuir)Also, I have full access to MC at this point, so what I'm doing for @EJB injection is to lookup the EjbReferenceResolver MC bean and use it to get the JNDI name for the injection point.
-
2. Re: Looking up a PU from @PersistenceContext annotation
wolfc Jan 7, 2009 12:53 PM (in response to pmuir)After injecting PersistenceUnitDependencyResolver, this piece of pseudo code should do the trick:
String beanName = persistenceUnitDependencyResolver.resolvePersistenceUnitSupplier(deploymentUnit, persistenceUnitName); PersistenceUnitDeployment deployment = lookup(beanName); ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory(); return new InjectedEntityManagerFactory(managedFactory);
Although PersistenceUnitDeployment is an internal. Maybe we should add a simple utility class to jpa-deployers.