title: Injecting EntityManager Vs. EntityManagerFactory
body: <p>A long question, please bear with me.</p>
  
  <p>We are using Spring+JPA for a web application. My team is debating over injecting <code>EntityManagerFactory</code> in the <code>GenericDAO</code> (a DAO based on Generics something on the lines provided by APPFUSE, we do not use <code>JpaDaosupport</code> for some reason) over injecting an <code>EntityManager</code>. We are using "application managed persistence".</p>
  
  <p>The arguments against injecting a <code>EntityManagerFactory</code> is that its too heavy and so is not required, the <code>EntityManager</code> does what we need. Also, as Spring would create a new instance of a DAO for every web request(I doubt this) there are not going to be any concurrency issues as in the same <code>EntityManager</code> instance is shared by two threads.</p>
  
  <p>The argument for injecting EFM is that its a good practice over all its always good to have a handle to a factory.</p>
  
  <p>I am not sure which is the best approach, can someone please enlighten me?</p>