Last active
March 10, 2019 12:23
-
-
Save ezhov-da/c613fc295104c2c67ee9c0558335c6fe to your computer and use it in GitHub Desktop.
java hibernate hibernate util class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[code:]JAVA[:code] | |
import org.hibernate.cfg.Configuration; | |
import org.hibernate.SessionFactory; | |
public class HibernateUtil { | |
private static final SessionFactory sessionFactory; | |
static { | |
try { | |
sessionFactory = new Configuration().configure().buildSessionFactory(); | |
} catch (Throwable ex) { | |
System.err.println(«Initial SessionFactory creation failed.» + ex); | |
throw new ExceptionInInitializerError(ex); | |
} | |
} | |
public static SessionFactory getSessionFactory() { | |
return sessionFactory; | |
} | |
} | |
[/code] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment