title: @PersistenceContext is not applicable to parameters. How to inject EntityManager through a constructor?
body: <p>It is a best practice to use constructor injection. However I can't acheive this with <code>@PersistenceContext</code>.</p>
  
  <p>I would like to have the following constructor:</p>
  
  <pre><code>private final EntityManager entityManager;
  
  @Autowired
  public MyService(@PersistenceContext EntityManager entityManager) {
      this.entityManager = entityManager;
  }
  </code></pre>
  
  <p>But I can't since <code>@PersistenceContext</code> is only applicable to <code>TYPE</code>, <code>METHOD</code> and <code>FIELD</code>.</p>
  
  <p><strong>Q:</strong> How do I inject <em>a container-managed</em> <code>EntityManager</code> through constructor injection?</p>