Skip to content

Instantly share code, notes, and snippets.

@dmitry-osin
Created October 27, 2018 20:31
Show Gist options
  • Save dmitry-osin/f00cc227efb7a1a7f7f4336ee94d14f0 to your computer and use it in GitHub Desktop.
Save dmitry-osin/f00cc227efb7a1a7f7f4336ee94d14f0 to your computer and use it in GitHub Desktop.
package pw.osin.example.data;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
public enum PersistenceHolder {
INSTANCE;
private EntityManager entityManager;
public EntityManager getEntityManager() {
if (entityManager == null) {
entityManager = Persistence.createEntityManagerFactory("tweetPU").createEntityManager();
}
return entityManager;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment