Project

General

Profile

Revision 11

View differences:

HibernateUtil.java
7 7
 *
8 8
 * @author Andrej Cimpersek
9 9
 */
10
public class HibernateUtil {
10 11

  
11
public class HibernateUtil {
12
  private static final SessionFactory sessionFactory;
13
  static {
14
    try {
15
      // Create the SessionFactory from hibernate.cfg.xml
16
      sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
17
    } catch (Throwable ex) {
18
      // Make sure you log the exception, as it might be swallowed
19
      System.err.println("Initial SessionFactory creation failed." + ex);
20
      throw new ExceptionInInitializerError(ex);
12
    private static final SessionFactory sessionFactory;
13

  
14
    static {
15
        try {
16
            // Create the SessionFactory from hibernate.cfg.xml
17
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
18
        } catch (Throwable ex) {
19
            // Make sure you log the exception, as it might be swallowed
20
            System.err.println("Initial SessionFactory creation failed." + ex);
21
            throw new ExceptionInInitializerError(ex);
22
        }
21 23
    }
22
  }
23 24

  
24
  public static SessionFactory getSessionFactory() {
25
    return sessionFactory;
26
  }
27
}
25
    public static SessionFactory getSessionFactory() {
26
        return sessionFactory;
27
    }
28
}

Also available in: Unified diff