diff --git a/src/main/java/com/example/cosmos_serversb/models/SessionManager.java b/src/main/java/com/example/cosmos_serversb/models/SessionManager.java index d0595c1..dafe635 100644 --- a/src/main/java/com/example/cosmos_serversb/models/SessionManager.java +++ b/src/main/java/com/example/cosmos_serversb/models/SessionManager.java @@ -35,9 +35,15 @@ } public static void closeSession(){ - session.getTransaction().commit(); - session.close(); - session = null; + if(session != null) { + session.getTransaction().commit(); + session.close(); + session = null; + } + } + + public static SessionFactory getSessionFactory(){ + return sessionFactory; } @@ -66,8 +72,4 @@ } } - public static SessionFactory getSessionFactory(){ - return sessionFactory; - } - }