if(sessionFactory == null)
try{
Configuration cfg = new Configuration().configure("hibernate.cfg.xml");
StandardServiceRegistryBuilder sb = new StandardServiceRegistryBuilder();
sb.applySettings(cfg.getProperties());
StandardServiceRegistry standardServiceRegistry = sb.build();
sessionFactory = cfg.buildSessionFactory(standardServiceRegistry);
sr = standardServiceRegistry;
} catch (Throwable ex) {
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex);