Skip to content

Instantly share code, notes, and snippets.

@ezhov-da
Last active March 10, 2019 12:23
Show Gist options
  • Save ezhov-da/c613fc295104c2c67ee9c0558335c6fe to your computer and use it in GitHub Desktop.
Save ezhov-da/c613fc295104c2c67ee9c0558335c6fe to your computer and use it in GitHub Desktop.
java hibernate hibernate util class
[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