/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package gov.hhs.fha.nhinc.common.connectionmanager.persistence; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; /** * This class will be used as a Utility Class to access the Data Object using Hibernate SessionFactory * @author svalluripalli */ public class HibernateUtil { private static final SessionFactory sessionFactory; static { try { // Create the SessionFactory from hibernate.cfg.xml sessionFactory = new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } /** * Method returns an instance of Hibernate SessionFactory * @return SessionFactory */ public static SessionFactory getSessionFactory() { return sessionFactory; } }