Will @PersistenceUnit close my EntityManagerFactory when application is destroyed?
-
24-06-2021 - |
Question
If i use the following
@PersistenceUnit(unitName="mongo")
EntityManagerFactory emf;
EntityManager em = emf.createEntityManager();
Will this annotation make sure that the EntityManagerFactory closes gracefully when application is destroyed?
Solution
Yes an injected EntityManagerFactory is automatically closed by the container.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow