andyshon

HibernateUtil.java

Oct 4th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package com.andyshon;
  2.  
  3. import org.hibernate.SessionFactory;
  4. import org.hibernate.cfg.Configuration;
  5.  
  6. /**
  7.  * Created by andys_000 on 02.10.2017.
  8.  */
  9. public class HibernateUtil {
  10.     private static final SessionFactory sessionFactory;
  11.     static {
  12.         try {
  13.             sessionFactory = new Configuration().configure().buildSessionFactory();
  14.         } catch (Throwable ex) {
  15.             System.err.println("Initial SessionFactory creation failed." + ex);
  16.             throw new ExceptionInInitializerError(ex);
  17.         }
  18.     }
  19.  
  20.     public static SessionFactory getSessionFactory() {
  21.         return sessionFactory;
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment