PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/web/DRCP/src/util/HibernateUtil.java

http://drcp.googlecode.com/
Java | 27 lines | 18 code | 7 blank | 2 comment | 0 complexity | 1cc874e06e4ee6a4cf6fe47b42e3e78a MD5 | raw file
 1package util;
 2
 3import org.hibernate.SessionFactory;
 4import org.hibernate.cfg.Configuration;
 5
 6public class HibernateUtil {
 7
 8    private static final SessionFactory sessionFactory;
 9
10    static {
11        try {
12            // Create the SessionFactory from hibernate.cfg.xml
13        	Configuration cfg = new Configuration().configure();        	
14        	sessionFactory = cfg.buildSessionFactory();
15        	
16        } catch (Throwable ex) {
17            // Make sure you log the exception, as it might be swallowed
18            System.err.println("Initial SessionFactory creation failed." + ex);
19            throw new ExceptionInInitializerError(ex);
20        }
21    }
22
23    public static SessionFactory getSessionFactory() {
24        return sessionFactory;
25    }
26
27}