title: Stateful bean injecting stateless bean, will they both use the same instance of EntityManagerFactory?
body: <p>I have a Stateful Bean injecting a JPA PersistenceUnit and another stateless bean. The stateless bean is injecting the same PersistenceUnit as well. My question is, will the EJB container inject the same instance of PersistenceUnit in both beans. I have to be very sure about the behaviour here.</p>
  
  <pre><code>@Stateful
  public class MyStatefulBean {
  
     @PersistenceUnit(unitName = "MY_PU")
     private EntityManagerFactory emf;
  
     @EJB
     MyStatelessLocal statelessEJB;
  
     public void doSomething() {
       // Question will statelessEJB use the same instance of EntityManagerFactory? 
       statelessEJB.doSomthingWithEntityManager();
     }
  }
  
  
  @Stateless
  public class MyStatelessBean {
  
     @PersistenceUnit(unitName = "MY_PU")
     private EntityManagerFactory emf;
  
     public void doSomthingWithEntityManager() {      
     }
  }
  </code></pre>
  
  <p>Any answers are welcome.</p>
  
  <p>Regards</p>