title: Entity manager best practices
body: <p>I would like to know which way is the best to define entity manager. I am using spring boot</p>
  
  <p>case 1) creating in spring service class like follows</p>
  
  <pre><code>@Service
  @Transactional
  public class DemoService {
  
      private static final Logger log = LoggerFactory.getLogger(DemoService.class);
  
      private EntityManagerFactory emf;
  
      public void getEntity(){
          final EntityManager em = emf.createEntityManager();
      }
  
      @PersistenceUnit
      public void setEntityManagerFactory(final EntityManagerFactory emf) {
          this.emf = emf;
      }
  
  }
  </code></pre>
  
  <p>Case 2.) Define a global entity manager and share it across all services. </p>
  
  <p>Note : Each service only reflects one single Entity definition.</p>