1 package org.hibernate.ce.auction.persistence; 2 3 import org.hibernate.*; 4 import org.hibernate.cfg.Configuration; 5 import org.apache.commons.logging.*; 6 7 17 public class HibernateUtilSimple { 18 19 private static Log log = LogFactory.getLog(HibernateUtil.class); 20 21 private static final SessionFactory sessionFactory; 22 23 static { 25 try { 26 sessionFactory = new Configuration().configure().buildSessionFactory(); 27 } catch (Throwable ex) { 28 log.error("Building SessionFactory failed.", ex); 31 throw new ExceptionInInitializerError (ex); 32 } 33 } 34 35 public static Session getSession() 36 throws HibernateException { 37 return sessionFactory.openSession(); 38 } 39 } 40 | Popular Tags |