Skip to content

Commit

Permalink
bedre sted å registrer monitorering
Browse files Browse the repository at this point in the history
  • Loading branch information
janolaveide committed Jun 2, 2021
1 parent 52b7ffa commit e29ae76
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ public EntityManager createEntityManager() {

private synchronized EntityManager createNewEntityManager(String key) {
if (!CACHE_FACTORIES.containsKey(key)) {
EntityManagerFactory f = createEntityManager(key);
CACHE_FACTORIES.put(key, f);
LOG.info("Muliggjør hibernate monitorering, slås på med hibernate.generate_statistics=true i de enkeltes persistence.xml");
HibernateMetrics.monitor(globalRegistry, f.unwrap(SessionFactory.class), EM_NAME);
CACHE_FACTORIES.put(key, createEntityManager(key));
}
var emf = CACHE_FACTORIES.get(key);
var em = emf.createEntityManager();
Expand All @@ -68,7 +65,10 @@ private void initConfig(EntityManager em, Map<String, Object> props) {
}

public EntityManagerFactory createEntityManager(String key) {
return Persistence.createEntityManagerFactory(key);
var emf = Persistence.createEntityManagerFactory(key);
LOG.info("Muliggjør hibernate monitorering, slås på med hibernate.generate_statistics=true i de enkeltes persistence.xml");
HibernateMetrics.monitor(globalRegistry, emf.unwrap(SessionFactory.class), EM_NAME);
return emf;
}

public void dispose(@Disposes EntityManager mgr) {
Expand Down

0 comments on commit e29ae76

Please sign in to comment.