@Test public void getEntityManager() { EntityManager em = JPASessionUtil.getEntityManager("utiljpa"); em.close(); }
@SuppressWarnings("WeakerAccess") public static synchronized EntityManager getEntityManager(String persistenceUnitName) { persistenceUnits.putIfAbsent(persistenceUnitName, Persistence.createEntityManagerFactory(persistenceUnitName)); return persistenceUnits.get(persistenceUnitName) .createEntityManager(); }
JPASessionUtil { @SuppressWarnings("WeakerAccess") public static synchronized EntityManager getEntityManager(String persistenceUnitName) { persistenceUnits.putIfAbsent(persistenceUnitName, Persistence.createEntityManagerFactory(persistenceUnitName)); return persistenceUnits.get(persistenceUnitName) .createEntityManager(); } }
JPASessionUtil { @SuppressWarnings("WeakerAccess") public static synchronized EntityManager getEntityManager(String persistenceUnitName) { persistenceUnits.putIfAbsent(persistenceUnitName, Persistence.createEntityManagerFactory(persistenceUnitName)); return persistenceUnits.get(persistenceUnitName) .createEntityManager(); }  }
JPASessionUtil { @SuppressWarnings("WeakerAccess") public static synchronized EntityManager getEntityManager(String persistenceUnitName) { persistenceUnits.putIfAbsent(persistenceUnitName, Persistence.createEntityManagerFactory(persistenceUnitName)); return persistenceUnits.get(persistenceUnitName) .createEntityManager(); }  @SuppressWarnings("WeakerAccess") static synchronized EntityManager getEntityManager(String persistenceUnitName); static Session getSession(String persistenceUnitName); }
JPASessionUtil { @SuppressWarnings("WeakerAccess") public static synchronized EntityManager getEntityManager(String persistenceUnitName) { persistenceUnits.putIfAbsent(persistenceUnitName, Persistence.createEntityManagerFactory(persistenceUnitName)); return persistenceUnits.get(persistenceUnitName) .createEntityManager(); }  @SuppressWarnings("WeakerAccess") static synchronized EntityManager getEntityManager(String persistenceUnitName); static Session getSession(String persistenceUnitName);  }