Joaquín Reñé
2 days ago e6b4cd695cfc6c0d4b0ea53cc403a4384d0f4d69
securis/src/main/java/net/curisit/securis/ioc/EntityManagerProvider.java
....@@ -45,7 +45,7 @@
4545 log.info("EntityManagerFactory initialized correctly: {}", entityManagerFactory);
4646 } catch (Exception e) {
4747 log.error("Error creating EntityManagerFactory for persistence unit 'localdb'", e);
48
- entityManagerFactory = null;
48
+ throw new IllegalStateException("Could not initialize EntityManagerFactory", e);
4949 }
5050 }
5151
....@@ -56,17 +56,11 @@
5656 * @return a new EntityManager; caller must close it
5757 */
5858 public EntityManager getEntityManager() {
59
- try {
60
- if (entityManagerFactory == null) {
61
- log.error("EntityManagerFactory is null");
62
- return null;
63
- }
64
- EntityManager em = entityManagerFactory.createEntityManager();
65
- log.info("Created EntityManager: {}", em);
66
- return em;
67
- } catch (Exception e) {
68
- log.error("Error creating EntityManager", e);
69
- return null;
59
+ if (entityManagerFactory == null) {
60
+ throw new IllegalStateException("EntityManagerFactory is null");
7061 }
62
+ EntityManager em = entityManagerFactory.createEntityManager();
63
+ log.info("Created EntityManager: {}", em);
64
+ return em;
7165 }
7266 }