From e29ae764f9b459ce3237cfcde9ed4091b3d8b7fb Mon Sep 17 00:00:00 2001 From: Jan-Olav Eide Date: Wed, 2 Jun 2021 11:04:08 +0200 Subject: [PATCH] =?UTF-8?q?bedre=20sted=20=C3=A5=20registrer=20monitorerin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nav/vedtak/felles/jpa/EntityManagerProducer.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/felles/db/src/main/java/no/nav/vedtak/felles/jpa/EntityManagerProducer.java b/felles/db/src/main/java/no/nav/vedtak/felles/jpa/EntityManagerProducer.java index f6a1943b6..a0fb5aa42 100644 --- a/felles/db/src/main/java/no/nav/vedtak/felles/jpa/EntityManagerProducer.java +++ b/felles/db/src/main/java/no/nav/vedtak/felles/jpa/EntityManagerProducer.java @@ -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(); @@ -68,7 +65,10 @@ private void initConfig(EntityManager em, Map 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) {