Mark Spritzler wrote:You need to inject the EntityManagerFactory, then in your methods call the getEntityManager() of the factory. This is needed because you can't create an EntityManager up front, with a Connection, and have your Repository hold on to it forever. This is bad resource holding. So it isn't possible for you to inject an EntityManager.
I hope that helps and makes sense. It is an extremely correct and best implementation to not allow you to inject an EntityManager.
Good Luck
Mark
Hi Mark, I was under the impression that the EM injected by spring or via the @PersistenceContext is a proxy only. I'm concerned now because in my code I
inject the EM via the @PersistenceContext annotation, managed by spring. Can you clarify? Do I need to change my code to inject a factory and grab the EM from the factory instead?
thanks...
billworth