【问题标题】:Will @PersistenceUnit close my EntityManagerFactory when application is destroyed?当应用程序被销毁时,@PersistenceUnit 会关闭我的 EntityManagerFactory 吗?
【发布时间】:2012-08-01 15:30:41
【问题描述】:

如果我使用以下内容

@PersistenceUnit(unitName="mongo")
EntityManagerFactory emf;

EntityManager em = emf.createEntityManager();

这个注解会确保 EntityManagerFactory 在应用程序被销毁时正常关闭吗?

【问题讨论】:

    标签: java annotations entitymanager persistence-unit


    【解决方案1】:

    是的,注入的 EntityManagerFactory 会被容器自动关闭。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-16
      • 1970-01-01
      • 1970-01-01
      • 2013-11-28
      • 1970-01-01
      • 2013-02-02
      相关资源
      最近更新 更多