Do I have to close() every EntityManager?

后端 未结 3 1524
半阙折子戏
半阙折子戏 2020-12-22 19:53

I have just started migrating my homegrown persistence framework to JPA.

Given that the persistence frameworks hide a lot of the plumbing, I\'m interested in knowing

3条回答
  •  天命终不由人
    2020-12-22 20:39

    I have obtained EntityManager using @PersistenceContext annotation in my repository. I can see that after the connectionpools reaches its maxPoolSize it does not get cleaned up.

    However if I create EntityManager using EntityManagerFactory and call entitymanager.close() then connections are getting cleaned up. I am using c3p0 as connectionpool library.

提交回复
热议问题