-
-
Save anonymous/e4be34bff32545e25ba1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class PersistenceUnit { | |
@javax.persistence.PersistenceUnit(unitName = "default") | |
private EntityManagerFactory entityManagerFactory; | |
@Produces | |
@RequestScoped | |
public EntityManager create() { | |
return entityManagerFactory.createEntityManager(); | |
} | |
public void dispose(@Disposes final EntityManager entityManager) { | |
if (entityManager.isOpen()) { | |
entityManager.close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment