Will @PersistenceUnit close my EntityManagerFactory when application is destroyed?

211 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

Yes an injected EntityManagerFactory is automatically closed by the container.