I searched a lot to determine how spring JPA closes the EntityManager connection after opening it. I used @PersistenceContext to inject the Transactional EntityManager into my DAOs, and that means spring will take care of creating and closing the EntityManager for me. However, in my previous implementation, I used to create and close the EntityManager from the DAO, which is now replaced with spring. Can someone help me figure out whether spring will close the EntityManager connection after the transaction is completed or maintain until the application is installed?
FYI, I am not closing the EntityManager of my own guess, spring will close it for me as soon as the transaction is completed. I am afraid if this does not lead to a drain of resources at some point in time.
Rajib Relations
source share