代码之家  ›  专栏  ›  技术社区  ›  IAdapter

如何将EntityManager传递给@PostUpdate

  •  0
  • IAdapter  · 技术社区  · 16 年前

    1 回复  |  直到 16 年前
        1
  •  2
  •   Pablo Santa Cruz    16 年前

    您只需从上下文中检索EntityManager的实例,就可以像在任何其他实例上一样获取它:

    @PersistenceContext EntityManager em; // injected in your class
    

    EntityManager em = EntityManagerFactory.getEntityManager();