Created
July 27, 2015 11:53
-
-
Save ricston-git/580b2f5943ce15fb4b69 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
package com.ricston.entitymanager; | |
import javax.persistence.EntityManager; | |
import javax.persistence.EntityManagerFactory; | |
import javax.persistence.Persistence; | |
public class PoeticEntityManager { | |
private static PoeticEntityManager poeticEntityManager = new PoeticEntityManager(); | |
private EntityManagerFactory factory; | |
private EntityManager entityManager; | |
private PoeticEntityManager(){ | |
factory = Persistence.createEntityManagerFactory("PeoticPersistenceUnit"); | |
entityManager = factory.createEntityManager(); | |
} | |
public EntityManager getEntityManager(){ | |
return poeticEntityManager.entityManager; | |
} | |
public void close(){ | |
poeticEntityManager.entityManager.close(); | |
poeticEntityManager.factory.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment