public static void closeEntityManagers() { EntityManager em = JpaUtil.getThreadEntityManager().get(); if (em != null) { EntityTransaction transaction = em.getTransaction(); if (transaction.isActive()) { transaction.commit(); } em.close(); JpaUtil.getThreadEntityManager().set(null); } }
public RepositorioGenerico(Class classe) { this.entityManager = JpaUtil.getEntityManager(); this.classePersistente = classe; this.log = LogManager.getLogger(classePersistente.getName()); }