Joined: Fri Aug 02, 2013 11:27 pm Posts: 1
|
I am using below code to get sessionFactory object but I am getting an exception. How can I solve this exception.
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
import org.hibernate.SessionFactory; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration;
/** * Hibernate Utility class with a convenient method to get Session Factory * object. * * @author Mithun */ public class NewHibernateUtil {
private static final SessionFactory sessionFactory; static { try { // Create the SessionFactory from standard (hibernate.cfg.xml) // config file. sessionFactory =new AnnotationConfiguration().configure().buildSessionFactory(); //new Configuration().buildSessionFactory(); } catch (Throwable ex) { // Log the exception. System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; } }
|
|