1 package com.iqjava.util;
2
3 import org.hibernate.SessionFactory;
4 import org.hibernate.cfg.Configuration;
5
6 public class HibernateUtil {
7 private static final SessionFactory sessionFactory;
8 static {
9 try {
10 sessionFactory = new Configuration().configure()
11 .buildSessionFactory();
12 } catch (Throwable ex) {
13 System.err.println("Initial SessionFactory creation failed." + ex);
14 throw new ExceptionInInitializerError(ex);
15 }
16 }
17
18 public static SessionFactory getSessionFactory() {
19 return sessionFactory;
20 }
21 }