/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gov.hhs.fha.nhinc.patientcorrelation.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;
    }
}

@@ -163,76 +163,287 @@
 ort 
-org.hibernate.SessionFactory;%0Aimport org.hibernate.cfg.Configuration
+gov.hhs.fha.nhinc.properties.HibernateAccessor;%0Aimport gov.hhs.fha.nhinc.nhinclib.NhincConstants;%0Aimport org.hibernate.SessionFactory;%0Aimport org.hibernate.cfg.Configuration;%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0Aimport java.io.File
 ;%0A%0A/
@@ -658,24 +658,93 @@
 ionFactory;%0A
+    private static Log log = LogFactory.getLog(HibernateUtil.class);%0A
     static %7B
@@ -881,16 +881,31 @@
 nfigure(
+getConfigFile()
 ).buildS
@@ -1043,26 +1043,17 @@
     
-System.err.println
+log.error
 (%22In
@@ -1364,20 +1364,425 @@
 ionFactory;%0A
+    %7D%0A    private static File getConfigFile()%7B%0A        File result = null;%0A%0A        try%0A        %7B%0A            result = HibernateAccessor.getHibernateFile(NhincConstants.HIBERNATE_PATIENT_CORRELATION);%0A        %7D%0A        catch (Exception ex)%0A        %7B%0A            log.error(%22Unable to load %22 + NhincConstants.HIBERNATE_PATIENT_CORRELATION + %22 %22 + ex.getMessage(), ex );%0A        %7D%0A%0A%0A        return result;%0A%0A%0A
     %7D%0A%7D%0A

task 19826